Boost logo

Boost :

From: Sean Kelly (sean_at_[hidden])
Date: 2004-01-24 16:05:03

The condition object is needlessly complex for instances where a thread
must wait on a signal but isn't immediately concerned with shared data.
Basically, I'd like a simplified version of condition that supports wait
and timed_wait without the predicate and without the need to pass a mutex.
It might be used like this:

mutex sync;
queue<T> mq;
event ev;

void add_message( T const& msg ) {
   lock l( sync );
    mq.add( msg );

void process_msgs() {
    // synchronized access to mq
    // acts on messages

void loop() {
    for(;;) {

On the Windows side the event object could purely use the CreateEvent and
WaitForSingleObject calls. On the pthread side it could use a
internal mutex, boolean to indicate whether the event has been signalled,
and the cond_wait process from the condition object. Ideally, there
should be a way to specify on construction whether the event will
auto-reset or if it needs to be reset manually (as in the above example).

I've personally found that I use the above processing method far more than
what the condition object requires, and it would be nice to be able to
avoid any more synchronization code than necessary. Comments?


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