What sync object should i use?
Sean Kelly
sean at invisibleduck.org
Tue May 14 09:12:43 PDT 2013
I'm doing this from my phone so please bear with me.
You use a mutex in combination with a condition variable so you
can check the state of something to determine if waiting is
necessary. So the classic producer/consumer would be something
like:
T get() {
shnchronized(c.mutex) {
while (q.isEmpty)
c.wait();
return q.take();
}
}
void put(T val) {
synchronized (c.mutex) {
q.add(val);
c.notify();
}
}
You can emulate a Win32 event that stays flipped by
checking/setting a bool or int inside the mutex.
More information about the Digitalmars-d-learn
mailing list