diff 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
line wrap: on
line diff
--- a/dwt/dwthelper/Runnable.d	Wed Apr 16 20:36:33 2008 +0200
+++ b/dwt/dwthelper/Runnable.d	Wed Apr 16 20:36:50 2008 +0200
@@ -3,10 +3,37 @@
  */
 module dwt.dwthelper.Runnable;
 
+
+import tango.core.Tuple;
+import tango.core.Traits;
+
 public interface Runnable  {
 
     public abstract void run();
 
 }
 
+class _DgRunnableT(Dg,T...) : Runnable {
 
+    alias ParameterTupleOf!(Dg) DgArgs;
+    static assert( is(DgArgs == Tuple!(T)),
+                "Delegate args not correct" );
+
+    Dg dg;
+    T t;
+
+    private this( Dg dg, T t ){
+        this.dg = dg;
+        static if( T.length > 0 ){
+            this.t = t;
+        }
+    }
+
+    void run( ){
+        dg(t);
+    }
+}
+
+_DgRunnableT!(Dg,T) dgRunnable(Dg,T...)( Dg dg, T args ){
+    return new _DgRunnableT!(Dg,T)(dg,args);
+}
\ No newline at end of file