Opened 8 years ago
Closed 7 years ago
#11174 closed Bugs (fixed)
boost::condition_variable::timed_wait with predicate unexpectedly wakes up while should wait infinite
| Reported by: | Owned by: | viboes | |
|---|---|---|---|
| Milestone: | Boost 1.60.0 | Component: | thread |
| Version: | Boost 1.57.0 | Severity: | Regression |
| Keywords: | Cc: |
Description (last modified by )
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
}
Change History (9)
comment:1 by , 8 years ago
| Description: | modified (diff) |
|---|---|
| Owner: | changed from to |
| Status: | new → assigned |
comment:2 by , 7 years ago
| Milestone: | To Be Determined → Boost 1.59.0 |
|---|
comment:3 by , 7 years ago
| Milestone: | Boost 1.59.0 → Boost 1.60.0 |
|---|
comment:4 by , 7 years ago
comment:5 by , 7 years ago
| Milestone: | Boost 1.60.0 → To Be Determined |
|---|
comment:7 by , 7 years ago
Sorry for the delayed reply.
timeToWait is a boost::posix_time::time_duration.
I was referring to the predicate overload of timed_wait. Which wasn't fixed in #9708 (see https://github.com/boostorg/thread/commit/68dc454a665a54ab505336860401195dc356fd48#diff-c76416498c6a49103cfc4dbeb4c527e4R363). Seems your April commit has fixed this -- https://github.com/boostorg/thread/commit/385eefd3b3d29a52df89fd95bdc27101010dab69
Can provide a repro (which I should have done in the first place) if it helps close this off?
comment:9 by , 7 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |

Sorry I missed your ticket. To what other overload are you referring to? What is the type of your timeToWait?