view java/src/java/lang/Runnable.d @ 0:6dd524f61e62

add dwt win and basic java stuff
author Frank Benoit <benoit@tionex.de>
date Mon, 02 Mar 2009 14:44:16 +0100
parents
children 9b96950f2c3c
line wrap: on
line source

/**
 * Authors: Frank Benoit <benoit@tionex.de>
 */
module java.lang.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: "~DgArgs.stringof~" vs "~T.stringof );

    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);
}