From f2763d6d60f64447d24d6af806e25e8c684d3e3d Mon Sep 17 00:00:00 2001 From: theuni Date: Thu, 13 Jun 2013 23:39:54 -0400 Subject: [PATCH 1/2] fixed: include boost header as necessary Without this include, sometimes BOOST_VERSION was defined and sometimes it was not, depending on which includes came before it. The result was a random mix of sleep or sleep_for for boost versions >= 1.50. --- src/util.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/util.h b/src/util.h index 2272ed02..ae33fb4e 100644 --- a/src/util.h +++ b/src/util.h @@ -20,6 +20,7 @@ #include #include +#include #include #include #include From e2654c8d280fbe77920960009f337d3f3c6772b6 Mon Sep 17 00:00:00 2001 From: theuni Date: Thu, 13 Jun 2013 23:46:08 -0400 Subject: [PATCH 2/2] fixed: don't use thread::sleep_for where it's known to be broken Fixes #2690. --- src/util.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/util.h b/src/util.h index ae33fb4e..9173b5bb 100644 --- a/src/util.h +++ b/src/util.h @@ -105,7 +105,11 @@ T* alignup(T* p) inline void MilliSleep(int64 n) { -#if BOOST_VERSION >= 105000 +// Boost's sleep_for was uninterruptable when backed by nanosleep from 1.50 +// until fixed in 1.52. Use the deprecated sleep method for the broken case. +// See: https://svn.boost.org/trac/boost/ticket/7238 + +#if BOOST_VERSION >= 105000 && (!defined(BOOST_HAS_NANOSLEEP) || BOOST_VERSION >= 105200) boost::this_thread::sleep_for(boost::chrono::milliseconds(n)); #else boost::this_thread::sleep(boost::posix_time::milliseconds(n));