Bug report from Hans Fugal. The callback occlusion detection was borked for receive() and receiveTimeout(). It was failing if the final parameter was a Variant both because of an off-by-1 error and because the test should have been in a "static if" instead of just an "if" block. Unit tests forthcoming.

This commit is contained in:
Sean Kelly 2010-08-22 11:37:50 +00:00
parent 9ce4fbb9f3
commit b78bc4c59d

View file

@ -107,6 +107,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; MessageBox mbox;
bool[Tid] links; bool[Tid] links;
Tid owner; Tid owner;
@ -374,29 +400,7 @@ private void _send(T...)( MsgType type, Tid tid, T vals )
*/ */
void receive(T...)( T ops ) void receive(T...)( T ops )
{ {
foreach( i, t1; T ) checkops( ops );
{
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" );
}
}
}
mbox.get( ops ); mbox.get( ops );
} }
@ -437,6 +441,7 @@ receiveOnlyRet!(T) receiveOnly(T...)()
*/ */
bool receiveTimeout(T...)( long ms, T ops ) bool receiveTimeout(T...)( long ms, T ops )
{ {
checkops( ops );
static enum long TICKS_PER_MILLI = 10_000; static enum long TICKS_PER_MILLI = 10_000;
return mbox.get( ms * TICKS_PER_MILLI, ops ); return mbox.get( ms * TICKS_PER_MILLI, ops );
} }