Mercurial > projects > dwt-addons
diff dwtx/jface/util/SafeRunnable.d @ 104:04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
These new wrappers now use the tango.util.containers instead of the tango.util.collections.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Thu, 07 Aug 2008 15:01:33 +0200 |
parents | 46a6e0e6ccd4 |
children |
line wrap: on
line diff
--- a/dwtx/jface/util/SafeRunnable.d Sun Aug 03 17:01:51 2008 +0200 +++ b/dwtx/jface/util/SafeRunnable.d Thu Aug 07 15:01:33 2008 +0200 @@ -60,7 +60,7 @@ /* * (non-Javadoc) - * + * * @see dwtx.core.runtime.ISafeRunnable#handleException(java.lang.Throwable) */ public void handleException(Exception e) { @@ -184,3 +184,31 @@ } } + +import tango.core.Tuple; +import tango.core.Traits; + +class _DgSafeRunnableT(Dg,T...) : SafeRunnable { + + 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; + } + } + + public void run( ){ + dg(t); + } +} + +public _DgSafeRunnableT!(Dg,T) dgSafeRunnable(Dg,T...)( Dg dg, T args ){ + return new _DgSafeRunnableT!(Dg,T)(dg,args); +}