On Tuesday, 14 May 2013 at 17:59:55 UTC, Heinz wrote:
Guys, this is a precise example of what i'm trying to do.
You'll notice that there're 2 ways of waking up the consumer:
/////////////////////////////////////////////////////////////////////
Condition cond; // Previously instantiated.
bool loop = false; // This variable determine if the consumer
should take the next iteration or wait until a thread calls
SetLoop(true).
Object my_variable; // A value used for comunicating producer
and consumer. It's not a prerequisite to be set for an
iteration to happen.
You also need to declare Condition as __gshared. If you don't,
each thread will see a different Condition object or null,
because by default, every D global variable goes to Thread Local
Storage.
Any variables meant to be shared between threads need to be
either '__gshared' or 'shared'. You could also declare other
shared data as 'shared', but I don't think that's what you want
here.
To list all global variables not declared as __gshared, you can
compile using the -vtls switch.
--jm