Boost logo

Boost :

From: Vadim Senchukov (bigwad_at_[hidden])
Date: 2004-05-21 05:03:55

On Win32 platform both notify_one and notify_all do a lot of work with
kernel objects whether there are any threads waiting on
 condition or no.

Can't we eliminate such overhead using pretty simple counter of waitng
threads like in code below? Or I've overlooked smth and code has subtle

    boost::mutex mtx;
    boost::condition cond;
    int waiting = 0;

    //waiting in some place
    boost::mutex::scoped_lock lk( mtx );
    while (!pred)
        cond.wait( lk );

   //notification in another place
    boost::mutex::scoped_lock lk( mtx );
    if ( waiting )

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