10 Feb
2006
10 Feb
'06
1:20 a.m.
David Greene wrote:
void push(int val) { LOG_NOLCK("push(): about to lock"); { lock_type lock(mutex); LOG_NOLCK("push(): locked"); queue.push(val);
lock_type full_lock(full_mutex); LOG_NOLCK("push(): about to unlock"); } full_condition.notify_all(); };
Whoops! This is a race condition. Because the full_lock is released, there's no guaratee the consumer is waiting on the condition and the signal may be lost. When I moved the lock after the inner brace, everything started working. -Dave