root/dwt/dwthelper/Runnable.d

Revision 311:02332a154347, 0.7 kB (checked in by Frank Benoit <benoit@tionex.de>, 3 months ago)

Improved Listeners access functions.

Line 
1 /**
2  * Authors: Frank Benoit <benoit@tionex.de>
3  */
4 module dwt.dwthelper.Runnable;
5
6
7 import tango.core.Tuple;
8 import tango.core.Traits;
9
10 public interface Runnable  {
11
12     public abstract void run();
13
14 }
15
16 class _DgRunnableT(Dg,T...) : Runnable {
17
18     alias ParameterTupleOf!(Dg) DgArgs;
19     static assert( is(DgArgs == Tuple!(T)),
20                 "Delegate args not correct: "~DgArgs.stringof~" vs "~T.stringof );
21
22     Dg dg;
23     T t;
24
25     private this( Dg dg, T t ){
26         this.dg = dg;
27         static if( T.length > 0 ){
28             this.t = t;
29         }
30     }
31
32     void run( ){
33         dg(t);
34     }
35 }
36
37 _DgRunnableT!(Dg,T) dgRunnable(Dg,T...)( Dg dg, T args ){
38     return new _DgRunnableT!(Dg,T)(dg,args);
39 }
Note: See TracBrowser for help on using the browser.