diff --git a/std/concurrency.d b/std/concurrency.d index 022aad033..2d126ca1e 100644 --- a/std/concurrency.d +++ b/std/concurrency.d @@ -106,6 +106,32 @@ private } } } + + void checkops(T...)( T ops ) + { + foreach( i, t1; T ) + { + static assert( is( t1 == function ) || is( t1 == delegate ) ); + alias ParameterTypeTuple!(t1) a1; + + static if( i < T.length - 1 ) + { + static assert( a1.length != 1 || !is( a1[0] == Variant ), + "function with arguments " ~ a1.stringof ~ + " occludes successive function" ); + + foreach( t2; T[i+1 .. $] ) + { + static assert( is( t2 == function ) || is( t2 == delegate ) ); + alias ParameterTypeTuple!(t2) a2; + + static assert( !is( a1 == a2 ), + "function with arguments " ~ a1.stringof ~ + " occludes successive function" ); + } + } + } + } MessageBox mbox; bool[Tid] links; @@ -374,29 +400,7 @@ private void _send(T...)( MsgType type, Tid tid, T vals ) */ void receive(T...)( T ops ) { - foreach( i, t1; T ) - { - static assert( is( t1 == function ) || is( t1 == delegate ) ); - alias ParameterTypeTuple!(t1) a1; - - if( i < T.length ) - { - static assert( a1.length != 1 || !is( a1[0] == Variant ), - "function with arguments " ~ a1.stringof ~ - " occludes successive function" ); - - foreach( t2; T[i+1 .. $] ) - { - static assert( is( t2 == function ) || is( t2 == delegate ) ); - alias ParameterTypeTuple!(t2) a2; - - static assert( !is( a1 == a2 ), - "function with arguments " ~ a1.stringof ~ - " occludes successive function" ); - } - } - } - + checkops( ops ); mbox.get( ops ); } @@ -437,6 +441,7 @@ receiveOnlyRet!(T) receiveOnly(T...)() */ bool receiveTimeout(T...)( long ms, T ops ) { + checkops( ops ); static enum long TICKS_PER_MILLI = 10_000; return mbox.get( ms * TICKS_PER_MILLI, ops ); }