Boost logo

Boost :

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


pdimov_at_[hidden] (Peter Dimov) wrote:

> From: <duncan_at_[hidden]>
>
> > 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.
>
> Could you elaborate on that? It is possible to 'lose' a wakeup since
> notifyThread() can be called several times while the thread is in the
> while loop, but what's the problem? The event will remain signalled.

So the event is not auto-reset? If so, what resets it?

--
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