Boost C++ Libraries: Ticket #11174: boost::condition_variable::timed_wait with predicate unexpectedly wakes up while should wait infinite https://svn.boost.org/trac10/ticket/11174 <p> This is a follow on from the closed bug <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/9708" title="#9708: Bugs: boost::condition_variable::timed_wait unexpectedly wakes up while ... (closed: fixed)">#9708</a>. 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. </p> <p> A fix for the non-predicate overload was merged for 1.56 but this wasn't applied for the other overloads of timed_wait. </p> <p> The current workaround we have is: </p> <pre class="wiki">bool timeoutReached = false; if(timeToWait.is_pos_infinity()) { waitHandle.wait(lock, boost::bind(&amp;ObjectPool::IsResourceReady, this, boost::ref(waitHandle))); } else { // timed_wait returns false if the timeout was reached timeoutReached = !waitHandle.timed_wait(lock, timeToWait, boost::bind(&amp;ObjectPool::IsResourceReady, this, boost::ref(waitHandle))); } if (timeoutReached) { // handle timeout } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11174 Trac 1.4.3 viboes Sat, 18 Apr 2015 04:58:05 GMT owner, status, description changed https://svn.boost.org/trac10/ticket/11174#comment:1 https://svn.boost.org/trac10/ticket/11174#comment:1 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Anthony Williams</span> to <span class="trac-author">viboes</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> <li><strong>description</strong> modified (<a href="/trac10/ticket/11174?action=diff&amp;version=1">diff</a>) </li> </ul> Ticket viboes Tue, 28 Apr 2015 15:02:47 GMT milestone changed https://svn.boost.org/trac10/ticket/11174#comment:2 https://svn.boost.org/trac10/ticket/11174#comment:2 <ul> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.59.0</span> </li> </ul> Ticket viboes Thu, 13 Aug 2015 06:58:37 GMT milestone changed https://svn.boost.org/trac10/ticket/11174#comment:3 https://svn.boost.org/trac10/ticket/11174#comment:3 <ul> <li><strong>milestone</strong> <span class="trac-field-old">Boost 1.59.0</span> → <span class="trac-field-new">Boost 1.60.0</span> </li> </ul> Ticket viboes Sat, 05 Sep 2015 14:43:54 GMT <link>https://svn.boost.org/trac10/ticket/11174#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11174#comment:4</guid> <description> <p> Sorry I missed your ticket. To what other overload are you referring to? What is the type of your timeToWait? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Mon, 07 Sep 2015 17:44:47 GMT</pubDate> <title>milestone changed https://svn.boost.org/trac10/ticket/11174#comment:5 https://svn.boost.org/trac10/ticket/11174#comment:5 <ul> <li><strong>milestone</strong> <span class="trac-field-old">Boost 1.60.0</span> → <span class="trac-field-new">To Be Determined</span> </li> </ul> Ticket viboes Wed, 23 Sep 2015 22:49:46 GMT <link>https://svn.boost.org/trac10/ticket/11174#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11174#comment:6</guid> <description> <p> PING!!! </p> </description> <category>Ticket</category> </item> <item> <author>zac.sims@…</author> <pubDate>Wed, 23 Sep 2015 23:21:51 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11174#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11174#comment:7</guid> <description> <p> Sorry for the delayed reply. </p> <p> timeToWait is a boost::posix_time::time_duration. </p> <p> I was referring to the predicate overload of timed_wait. Which wasn't fixed in <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/9708" title="#9708: Bugs: boost::condition_variable::timed_wait unexpectedly wakes up while ... (closed: fixed)">#9708</a> (see <a class="ext-link" href="https://github.com/boostorg/thread/commit/68dc454a665a54ab505336860401195dc356fd48#diff-c76416498c6a49103cfc4dbeb4c527e4R363"><span class="icon">​</span>https://github.com/boostorg/thread/commit/68dc454a665a54ab505336860401195dc356fd48#diff-c76416498c6a49103cfc4dbeb4c527e4R363</a>). Seems your April commit has fixed this -- <a class="ext-link" href="https://github.com/boostorg/thread/commit/385eefd3b3d29a52df89fd95bdc27101010dab69"><span class="icon">​</span>https://github.com/boostorg/thread/commit/385eefd3b3d29a52df89fd95bdc27101010dab69</a> </p> <p> Can provide a repro (which I should have done in the first place) if it helps close this off? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sun, 27 Sep 2015 13:28:29 GMT</pubDate> <title>milestone changed https://svn.boost.org/trac10/ticket/11174#comment:8 https://svn.boost.org/trac10/ticket/11174#comment:8 <ul> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.60.0</span> </li> </ul> <p> Thanks for the feedback. </p> Ticket viboes Sun, 27 Sep 2015 13:41:20 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/11174#comment:9 https://svn.boost.org/trac10/ticket/11174#comment:9 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <blockquote> <p> <a class="ext-link" href="https://github.com/boostorg/thread/commit/730cb550e6d969520c3f39e0ddf5d80351bddf3a"><span class="icon">​</span>https://github.com/boostorg/thread/commit/730cb550e6d969520c3f39e0ddf5d80351bddf3a</a> </p> </blockquote> Ticket