Subject: [Boost-bugs] [Boost C++ Libraries] #9856: condition_variable::wait_for returns wrong cv_status on timeout.
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-04-08 18:39:24
#9856: condition_variable::wait_for returns wrong cv_status on timeout.
---------------------------------------------------+----------------------
Reporter: pi88el@⦠| Owner: anthonyw
Type: Bugs | Status: new
Milestone: To Be Determined | Component: thread
Version: Boost 1.55.0 | Severity: Problem
Keywords: condition_variable wait_for cv_status |
---------------------------------------------------+----------------------
'''The following bug seems to work on *nix systems. But not on Windows 7
with Visual Studio 2013 Express.'''[[BR]]
If a condition variable is waiting for a defined amount of time, sometimes
(nearly always) the returned cv_status is wrong.
{{{
int main() {
mutex mtx;
condition_variable cond;
unique_lock<mutex> lk(mtx);
std::cout << BOOST_VERSION << "\n";
for(int i=0; i<10; i++) {
std::cout << i << " : " << chrono::steady_clock::now() << "\n";
if (cv_status::no_timeout == cond.wait_for(lk,
chrono::seconds(1)))
std::cout << "no_timeout\n";
}
}
}}}
While the condition is '''never''' notified, i get '''no_timeout'''.[[BR]]
debuging the code:
{{{
steady_clock::time_point c_now = steady_clock::now();
do_wait(lock, ceil<milliseconds>(d).count());
return steady_clock::now() - c_now < d ? cv_status::no_timeout :
cv_status::timeout;
}}}
'''steady_clock::now() - c_now < d''' is ''true''. It seems do_wait is
sleeping to short.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/9856> 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:16 UTC