Boost logo

Boost Users :

Subject: Re: [Boost-users] [boost-thread] error in the docs???
From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2009-03-18 19:38:03


Steven, hi!

thanks for the answer!

On Thu, Mar 19, 2009 at 12:13 AM, Steven Watanabe <watanabesj_at_[hidden]>wrote:

> AMDG
>
>
> wait returns when the predicate is true, so the docs are correct.
>
> In Christ,
> Steven Watanabe

Did you test it? In my case wait returns when the predicate is false. I use
an empty circular buffer and call from the same thread this code:

        using namespace boost;

        scoped_lock lock(mutex_);
        wait_for_free_slots_.wait(lock, bind(&buffer_type::full, buffer_));
//wait_for_free_slots_ is a condition variable

        buffer_.push_back(item);
        wait_for_items_.notify_all();

This line returns immediately
wait_for_free_slots_.wait(lock, bind(&buffer_type::full, buffer_));
//wait_for_free_slots_ is a condition variable

If you inverse the predicate it blocks forever.

Thanks,
Ovanes



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net