Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-08-13 13:51:17


From: "Alexander Terekhov" <terekhov_at_[hidden]>

> > synchronized_queue<int> q;

Actually the queue need not even be synchronized. :-)

> > event e;
> ^^^^^^^
> auto-reset event, i guess..

Yep.

> > Did I utterly miss the point? :-)
>
> probably. you have introduced a race
> condition which could result in q.pop()
> throwing "queue empty" exception; unless
> you have only one worker thread.

Yep, one queue per thread. Just like the original example - one CV per
thread - unless I misinterpreted it.

Notifying a pool of threads (load balancing) is a different story.

--
Peter Dimov
Multi Media Ltd.

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