Subject: [Boost-bugs] [Boost C++ Libraries] #13599: condition_variable::timed_wait never returns
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2018-06-14 03:04:33
#13599: condition_variable::timed_wait never returns
------------------------------+------------------------------
Reporter: steven.cook@⦠| Owner: Anthony Williams
Type: Bugs | Status: new
Milestone: To Be Determined | Component: thread
Version: Boost 1.65.0 | Severity: Problem
Keywords: |
------------------------------+------------------------------
boost::condition_variable::timed_wait never returns if compiled with
-DBOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC.
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.
This can be worked around by using condition_variable::wait_for.
The following simple test program demonstrates the problem in that it
hangs forever. Removing the #define makes it return after one second.
{{{
#define BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC
#include <boost/thread.hpp>
#include <iostream>
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 << "wait_for has returned" << std::endl;
return 0;
}
}}}
-- Ticket URL: <https://svn.boost.org/trac10/ticket/13599> 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 : 2018-06-14 03:10:29 UTC