From 82eed2ca6d3b1573461ebcae19a9096eeff50799 Mon Sep 17 00:00:00 2001 From: "Vicente J. Botet Escriba" Date: Sun, 17 Sep 2017 19:09:09 +0200 Subject: [PATCH] make use of do_wait_until when BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC is defined as proposed by Austin Beer.. --- src/pthread/thread.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/pthread/thread.cpp b/src/pthread/thread.cpp index 41aa7ced..ace00fa3 100644 --- a/src/pthread/thread.cpp +++ b/src/pthread/thread.cpp @@ -445,6 +445,12 @@ namespace boost # endif # elif defined(BOOST_HAS_NANOSLEEP) && !defined(BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC) nanosleep(&ts.get(), 0); + # elif defined(BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC) + const detail::internal_timespec_timepoint& ts2 = detail::internal_timespec_clock::now() + ts; + mutex mx; + unique_lock lock(mx); + condition_variable cond; + while (cond.do_wait_until(lock, ts2)) {} # else mutex mx; unique_lock lock(mx); @@ -487,6 +493,9 @@ namespace boost { void BOOST_THREAD_DECL sleep_for(const detail::timespec_duration& ts) { +#if 0 + boost::this_thread::no_interruption_point::hidden::sleep_for(ts); +#else // VBE boost::detail::thread_data_base* const thread_info=boost::detail::get_current_thread_data(); if(thread_info) @@ -498,6 +507,7 @@ namespace boost { boost::this_thread::no_interruption_point::hidden::sleep_for(ts); } +#endif } void BOOST_THREAD_DECL sleep_until(const detail::internal_timespec_timepoint& ts)