mirror of
https://github.com/dlang/phobos.git
synced 2025-04-29 14:40:30 +03:00
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:
parent
9ce4fbb9f3
commit
b78bc4c59d
1 changed files with 28 additions and 23 deletions
|
@ -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 );
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue