Boost logo

Threads-Devel :

From: vicente.botet (vicente.botet_at_[hidden])
Date: 2008-04-14 11:22:35


Hello,

which is the expected behaviour of condition variable wait when unique_lock is not locked

boost::condition_variable cond;
boost::mutex mut;
bool data_ready;

void process_data();

void wait_for_data_to_process()
{
    boost::unique_lock<boost::mutex> lock(mut);
    while(!data_ready)
    {
        if (some_condition_or_bug ) {
            lock.unlock();
        }
        cond.wait(lock); // <<<<<<<< ?????????
    }
    process_data();
}

Best regards
_____________________
Vicente Juan Botet Escriba
_______________________________

inline void condition_variable::wait(unique_lock<mutex>& m)
{
detail::interruption_checker check_for_interruption(&cond);
BOOST_VERIFY(!pthread_cond_wait(&cond,m.mutex()->native_handle()));
}



Threads-Devel list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk