comparison dwt/dwthelper/Runnable.d @ 206:cca980503056

sync with dwt-linux, removed the simple.d
author Frank Benoit <benoit@tionex.de>
date Wed, 16 Apr 2008 20:36:50 +0200
parents 5406a8f6526d
children d10ff1f47f84
comparison
equal deleted inserted replaced
205:6d1762e7ebb7 206:cca980503056
1 /** 1 /**
2 * Authors: Frank Benoit <benoit@tionex.de> 2 * Authors: Frank Benoit <benoit@tionex.de>
3 */ 3 */
4 module dwt.dwthelper.Runnable; 4 module dwt.dwthelper.Runnable;
5
6
7 import tango.core.Tuple;
8 import tango.core.Traits;
5 9
6 public interface Runnable { 10 public interface Runnable {
7 11
8 public abstract void run(); 12 public abstract void run();
9 13
10 } 14 }
11 15
16 class _DgRunnableT(Dg,T...) : Runnable {
12 17
18 alias ParameterTupleOf!(Dg) DgArgs;
19 static assert( is(DgArgs == Tuple!(T)),
20 "Delegate args not correct" );
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 }