setMaxMailboxSize
Byron Heads
wyverex.cypher at gmail.com
Thu Jun 17 14:41:45 PDT 2010
On Thu, 17 Jun 2010 21:31:10 +0000, Byron Heads wrote:
> is setMaxMailboxSize not implemented yet or is it bugged?
>
This is a little better example of it not working:
import core.sys.posix.unistd;
import std.stdio,
std.concurrency,
std.random;
enum MAX = 1;
void main()
{
auto a = spawn( &bar, thisTid );
setMaxMailboxSize( a, MAX, OnCrowding.block );
writeln( "BAR mailbox set to ", MAX );
auto b = spawn( &foo, thisTid, a );
}
void foo( Tid p, Tid t )
{
for( int x = 0; x < 5; ++x ) {
writeln( "FOO SEND ", x );
t.send( x );
writeln( "FOO READY" );
}
writeln( "FOO is done!" );
}
void bar( Tid p )
{
sleep( 1 );
for( int x = 0; x < 5; ++x ) {
writeln( "BAR READY" );
receive( (int x ) { writeln( "BAR got ", x );} );
sleep( 1 );
}
writeln( "BAR is done!" );
}
// Result
BAR mailbox set to 1
FOO SEND 0
FOO READY
FOO SEND 1
FOO READY
FOO SEND 2
FOO READY
FOO SEND 3
FOO READY
FOO SEND 4
FOO READY
FOO is done!
BAR READY
BAR got 0
BAR READY
BAR got 1
BAR READY
BAR got 2
BAR READY
BAR got 3
BAR READY
BAR got 4
BAR is done!
-B:wq
More information about the Digitalmars-d-learn
mailing list