Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2005-10-03 08:27:09

Keith Burton wrote:
> Peter Dimov wrote:
>> // blocking
>> void push( V const & v );
>> void pop( V & v );
>> };
> There does not appear to be any mechanism to shutdown an application
> which uses the blocking interface.
> Options that occur to me are :
> 1) destructor releases threads blocking on push / pop with :
> a) exception
> b) bool return
> 2) timeout parameter and bool return
> I think I would go for 1a

Yes... the lack of a general cancellation mechanism is a pain and I don't
like the idea of every component providing its own (incompatible) version of
that. But on the other hand this _is_ important in practice. I've decided to
temporarily ignore it for now and work on the rest. Maybe boost::condition
is the right place where the cancellation support needs to be implemented.

In one typical scenario that I have in mind, destructor unblocking doesn't
buy much; the queue is at file scope and its destructor is being run on
process exit, which will kill all blocked threads anyway. Awakening these
will simply slow down the exit. But the option may be worth exploring.

You are probably right that the interface is missing timed_push and
timed_pop in addition to try_push and try_pop.

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