Boost C++ Libraries: Ticket #13599: condition_variable::timed_wait never returns https://svn.boost.org/trac10/ticket/13599 <p> boost::condition_variable::timed_wait never returns if compiled with -DBOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC. </p> <p> this_thread::sleep and thread::timed_join exhibit the same problem, but both these functions are documented as deprecated. However condition_variable::timed_wait is not documented as deprecated. </p> <p> This can be worked around by using condition_variable::wait_for. </p> <p> The following simple test program demonstrates the problem in that it hangs forever. Removing the #define makes it return after one second. </p> <pre class="wiki">#define BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC #include &lt;boost/thread.hpp&gt; #include &lt;iostream&gt; int main( int argc, char* argv[] ) { boost::condition_variable cv; boost::mutex m; boost::mutex::scoped_lock lock( m ); cv.timed_wait( lock, boost::posix_time::seconds( 1 ) ); std::cout &lt;&lt; "wait_for has returned" &lt;&lt; std::endl; return 0; } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/13599 Trac 1.4.3 viboes Tue, 07 Aug 2018 06:58:51 GMT <link>https://svn.boost.org/trac10/ticket/13599#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13599#comment:1</guid> <description> <p> <code>condition_variable::timed_wait</code> should be documented as deprecated. </p> <p> Thanks for the report anyway, I would try to fix it. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Tue, 07 Aug 2018 06:59:07 GMT</pubDate> <title>owner, status changed https://svn.boost.org/trac10/ticket/13599#comment:2 https://svn.boost.org/trac10/ticket/13599#comment:2 <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> </ul> Ticket viboes Tue, 07 Aug 2018 12:12:25 GMT <link>https://svn.boost.org/trac10/ticket/13599#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13599#comment:3</guid> <description> <p> On which platform are you executing your program? Does the platform provide condition variables with monotonic clocks? </p> <p> In principle, Boost.Thread defines BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC when know that this is the case. You should define it only if you are sure the platform provides it and Boost.Thread doesn't do it itself. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Tue, 11 Sep 2018 21:29:43 GMT</pubDate> <title>type changed https://svn.boost.org/trac10/ticket/13599#comment:4 https://svn.boost.org/trac10/ticket/13599#comment:4 <ul> <li><strong>type</strong> <span class="trac-field-old">Bugs</span> → <span class="trac-field-new">Support Requests</span> </li> </ul> <p> Moved to support until we have answer to the questions </p> Ticket