digitalmars.D.learn - setMaxMailboxSize
- Byron Heads (37/37) Jun 17 2010 is setMaxMailboxSize not implemented yet or is it bugged?
- Byron Heads (58/60) Jun 17 2010 This is a little better example of it not working:
- torhu (3/4) Jun 17 2010 It's just an empty function currently. If you want to see for yourself,...
- Lars T. Kyllingstad (5/6) Jun 18 2010 It seems it got implemented today. :)
is setMaxMailboxSize not implemented yet or is it bugged?
This test program does not work right:
import core.sys.posix.unistd;
import std.stdio,
std.concurrency,
std.random;
void main()
{
auto a = spawn( &bar, thisTid );
setMaxMailboxSize( a, 1, OnCrowding.block );
writeln( "Mail box set" );
auto b = spawn( &foo, thisTid, a );
}
void foo( Tid p, Tid t )
{
t.send( 1 );
t.send( 2 );
t.send( 3 );
writeln( "FOO is done!" );
}
void bar( Tid p )
{
receive( (int x ) { writeln( "BAR got ", x );} );
sleep( 1 );
receive( (int x ) { writeln( "BAR got ", x );} );
sleep( 1 );
receive( (int x ) { writeln( "BAR got ", x );} );
sleep( 1 );
}
It prints:
Mail box set
BAR got 1
FOO is done!
BAR got 2
BAR got 3
foo should be getting blocked.
-B
Jun 17 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
Jun 17 2010
On 17.06.2010 23:31, Byron Heads wrote:is setMaxMailboxSize not implemented yet or is it bugged?It's just an empty function currently. If you want to see for yourself, it's in dmd2/src/phobos/std/concurrency.d.
Jun 17 2010
On Thu, 17 Jun 2010 21:31:10 +0000, Byron Heads wrote:is setMaxMailboxSize not implemented yet or is it bugged?It seems it got implemented today. :) http://www.dsource.org/projects/phobos/changeset/1662 You can use the SVN version of Phobos, or wait for the next release. -Lars
Jun 18 2010









Byron Heads <wyverex.cypher gmail.com> 