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