Mercurial > projects > dwt-win
annotate dwt/dwthelper/Runnable.d @ 311:02332a154347
Improved Listeners access functions.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Tue, 16 Sep 2008 15:19:38 +0200 |
parents | d10ff1f47f84 |
children |
rev | line source |
---|---|
248 | 1 /** |
0 | 2 * Authors: Frank Benoit <benoit@tionex.de> |
3 */ | |
4 module dwt.dwthelper.Runnable; | |
5 | |
206
cca980503056
sync with dwt-linux, removed the simple.d
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
6 |
cca980503056
sync with dwt-linux, removed the simple.d
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
7 import tango.core.Tuple; |
cca980503056
sync with dwt-linux, removed the simple.d
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
8 import tango.core.Traits; |
cca980503056
sync with dwt-linux, removed the simple.d
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
9 |
0 | 10 public interface Runnable { |
11 | |
12 public abstract void run(); | |
13 | |
14 } | |
15 | |
206
cca980503056
sync with dwt-linux, removed the simple.d
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
16 class _DgRunnableT(Dg,T...) : Runnable { |
0 | 17 |
206
cca980503056
sync with dwt-linux, removed the simple.d
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
18 alias ParameterTupleOf!(Dg) DgArgs; |
cca980503056
sync with dwt-linux, removed the simple.d
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
19 static assert( is(DgArgs == Tuple!(T)), |
311
02332a154347
Improved Listeners access functions.
Frank Benoit <benoit@tionex.de>
parents:
248
diff
changeset
|
20 "Delegate args not correct: "~DgArgs.stringof~" vs "~T.stringof ); |
206
cca980503056
sync with dwt-linux, removed the simple.d
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
21 |
cca980503056
sync with dwt-linux, removed the simple.d
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
22 Dg dg; |
cca980503056
sync with dwt-linux, removed the simple.d
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
23 T t; |
cca980503056
sync with dwt-linux, removed the simple.d
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
24 |
cca980503056
sync with dwt-linux, removed the simple.d
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
25 private this( Dg dg, T t ){ |
cca980503056
sync with dwt-linux, removed the simple.d
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
26 this.dg = dg; |
cca980503056
sync with dwt-linux, removed the simple.d
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
27 static if( T.length > 0 ){ |
cca980503056
sync with dwt-linux, removed the simple.d
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
28 this.t = t; |
cca980503056
sync with dwt-linux, removed the simple.d
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
29 } |
cca980503056
sync with dwt-linux, removed the simple.d
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
30 } |
cca980503056
sync with dwt-linux, removed the simple.d
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
31 |
cca980503056
sync with dwt-linux, removed the simple.d
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
32 void run( ){ |
cca980503056
sync with dwt-linux, removed the simple.d
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
33 dg(t); |
cca980503056
sync with dwt-linux, removed the simple.d
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
34 } |
cca980503056
sync with dwt-linux, removed the simple.d
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
35 } |
cca980503056
sync with dwt-linux, removed the simple.d
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
36 |
cca980503056
sync with dwt-linux, removed the simple.d
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
37 _DgRunnableT!(Dg,T) dgRunnable(Dg,T...)( Dg dg, T args ){ |
cca980503056
sync with dwt-linux, removed the simple.d
Frank Benoit <benoit@tionex.de>
parents:
0
diff
changeset
|
38 return new _DgRunnableT!(Dg,T)(dg,args); |
311
02332a154347
Improved Listeners access functions.
Frank Benoit <benoit@tionex.de>
parents:
248
diff
changeset
|
39 } |