Boost logo

Boost :

From: jpanzer_at_[hidden]
Date: 2000-08-10 15:35:21

jsiek_at_[hidden] wrote:

> William Kempf writes:
> > I wouldn't attach it to the condition, however. I'd pass the
> > predicate into the wait. Thus the condition can be used to track
> > different criteria.
> >
> > cond.wait((free1 > 10)(a));
> Why would you want to use the same condition variable with different
> criteria? (why not just use a different condition variable)

Example: Bounded queue. Producer thread adds an item only if
the queue size is less than 100, else it waits. Consumer removes
an item only if the queue size is greater than 0, else it waits. Two
different conditions, both of them dependent on the same

(Of course the producer also needs to be able to specify a timeout.)

John Panzer

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