Boost logo

Boost :

From: Alexander Terekhov (terekhov_at_[hidden])
Date: 2001-08-13 14:54:57

> > > synchronized_queue<int> q;
> Actually the queue need not even be synchronized. :-)

really ? and how do you prevent concurrent push/empty/pop ??

well, synchronizing it inside queue object is really an
overkill (with respect to your example). it should be
done "on top" (using extra mutex/CVs) instead; IMHO what
you should synchronize here is not a *queue* (with lock/
unlock on every method call) but rather worker threads
doing some *more complex operations* such as
"if !q.empty() m = q.pop() else wait".

sure you could move the synch. logic inside push/pop
and do not use empty at all (waiting inside pop for
!_empty and inside push for !_full), but then please
show me the new versions of push/pop which would work
(using events) with multiple threads on push and pop


Boost list run by bdawes at, gregod at, cpdaniel at, john at