Boost logo

Boost :

From: William Kempf (sirwillard_at_[hidden])
Date: 2000-08-10 16:41:47

--- In boost_at_[hidden], jpanzer_at_n... wrote:
> jsiek_at_l... 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
> > > different criteria.
> > >
> > > cond.wait((free1 > 10)(a));
> >
> > Why would you want to use the same condition variable with
> > 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.
> different conditions, both of them dependent on the same
> variable.
> (Of course the producer also needs to be able to specify a timeout.)

This can be implemented with either one condition using multiple
criteria or two conditions. There isn't really an example (at least
that I can think of) where one or the other is the only solution.
The question is, which is the better solution for the specific

William Kempf

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