Boost logo

Boost :

From: duncan_at_[hidden]
Date: 2001-08-13 13:16:09


pdimov_at_[hidden] (Peter Dimov) wrote:

> synchronized_queue<int> q;
> event e;
>
> void threadfunc()
> {
> for(;;)
> {
> waitFor(e);
>
> while(!q.empty())
> {
> int m = q.pop();
> if(m & 1) do_something_a();
> if(m & 2) do_something_b();
> if(m & 4) do_something_c();
> }
> }
> }
>
> void notifyThread(bool a, bool b, bool c)
> {
> q.push(a + 2 * b + 4 * c);
> e.raise();
> }
>
> Did I utterly miss the point? :-)

Surely notifyThread() can happen between end of while loop and before
the waitFor(e) is entered again. In which case you have a lost wakeup.

--
Duncan Harris, Sapio Design Ltd, Manchester, U.K.

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk