Condition Mutexes

dsimcha dsimcha at yahoo.com
Tue Oct 20 17:56:13 PDT 2009


I'm messing around w/ core.sync.  Does anyone know what I'm doing wrong in
this program?  It just hangs. If I could figure out ()##$) condition mutexes
(right now, I'm using busy spinning), I might have a decent implementation of
parallelForeach over ranges.

import core.sync.mutex, core.sync.condition, core.thread, std.stdio;

__gshared Condition condition;

void waitThenPrint() {
    condition.wait();
    writeln("FOO");
}

void main() {
    condition = new Condition( new Mutex() );
    auto T = new Thread(&waitThenPrint);
    T.start();
    condition.notify();  // Never wakes up and prints FOO.
}



More information about the Digitalmars-d mailing list