Subject: [Boost-bugs] [Boost C++ Libraries] #12949: using sleep_for in a thread context without including boost/thread/thread.hpp yields incorrect behaviour when BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC is defined
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-04-05 07:37:31
#12949: using sleep_for in a thread context without including
boost/thread/thread.hpp yields incorrect behaviour when
BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC is defined
----------------------+------------------------------
Reporter: rkaris@⦠| Type: Bugs
Status: new | Milestone: To Be Determined
Component: None | Version: Boost 1.63.0
Severity: Problem | Keywords:
----------------------+------------------------------
When defining a function f() in a compilation unit which uses
boost::thread::sleep_for() which does not include
<boost/thread/thread.hpp>, but another boost thread header,
function.h
{{{
#ifndef FUNCTION_H
#define FUNCTION_H
void f();
#endif
}}}
function.cpp:
{{{
#define BOOST_THREAD_VERSION 4
#define BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC
#include <boost/thread/condition_variable.hpp>
#include "function.h"
void f()
{
boost::this_thread::sleep_for(boost::chrono::milliseconds(10));
}
}}}
and defining a compilation unit which uses this function in a thread
context,
main.cpp:
{{{
#define BOOST_THREAD_VERSION 4
#define BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC
#include "function.h"
#include <boost/thread.hpp>
int main()
{
auto t = boost::thread([]
{
f();
});
t.join();
return 0;
}
}}}
the sleep_for() waits much long than expected when a monotonic clock is
used.
This has been tested with both boost versions 1.63.0 and 1.64.0 beta2.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/12949> 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-04-05 07:40:47 UTC