Re: [Boost-bugs] [Boost C++ Libraries] #11174: boost::condition_variable::timed_wait with predicate unexpectedly wakes up while should wait infinite

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #11174: boost::condition_variable::timed_wait with predicate unexpectedly wakes up while should wait infinite
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-04-18 04:58:05


#11174: boost::condition_variable::timed_wait with predicate unexpectedly wakes up
while should wait infinite
-------------------------------+------------------------
  Reporter: zac.sims@… | Owner: viboes
      Type: Bugs | Status: assigned
 Milestone: To Be Determined | Component: thread
   Version: Boost 1.57.0 | Severity: Regression
Resolution: | Keywords:
-------------------------------+------------------------
Changes (by viboes):

 * owner: anthonyw => viboes
 * status: new => assigned


Old description:

> This is a follow on from the closed bug 9708.
> boost::condition_variable::timed_wait(...,
> boost::posix_time::time_duration(boost::posix_time::pos_infin),
> predicate_type pred) always immediately returns false. The referenced bug
> suggests this worked in 1.44.
>
> A fix for the non-predicate overload was merged for 1.56 but this wasn't
> applied for the other overloads of timed_wait.
>
> The current workaround we have is:
>
> {{{
> bool timeoutReached = false;
> if(timeToWait.is_pos_infinity())
> {
> waitHandle.wait(lock, boost::bind(&ObjectPool::IsResourceReady, this,
> boost::ref(waitHandle)));
> }
> else
> {
> // timed_wait returns false if the timeout was reached
> timeoutReached = !waitHandle.timed_wait(lock, timeToWait,
> boost::bind(&ObjectPool::IsResourceReady, this, boost::ref(waitHandle)));
> }
>
> if (timeoutReached)
> {
> // handle timeout
> }
> }}}

New description:

 This is a follow on from the closed bug #9708.
 boost::condition_variable::timed_wait(...,
 boost::posix_time::time_duration(boost::posix_time::pos_infin),
 predicate_type pred) always immediately returns false. The referenced bug
 suggests this worked in 1.44.

 A fix for the non-predicate overload was merged for 1.56 but this wasn't
 applied for the other overloads of timed_wait.

 The current workaround we have is:

 {{{
 bool timeoutReached = false;
 if(timeToWait.is_pos_infinity())
 {
     waitHandle.wait(lock, boost::bind(&ObjectPool::IsResourceReady, this,
 boost::ref(waitHandle)));
 }
 else
 {
     // timed_wait returns false if the timeout was reached
     timeoutReached = !waitHandle.timed_wait(lock, timeToWait,
 boost::bind(&ObjectPool::IsResourceReady, this, boost::ref(waitHandle)));
 }

 if (timeoutReached)
 {
     // handle timeout
 }
 }}}

--
-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/11174#comment:1>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:18 UTC