From 9c25df34026f8ab5ca233483e1200fbde4f81994 Mon Sep 17 00:00:00 2001 From: Anthony Williams Date: Fri, 21 May 2010 16:59:56 +0000 Subject: [PATCH] Sleeping for a negative time is same as sleeping for 0ms, fix for issue #3178 [SVN r62122] --- include/boost/thread/win32/thread_data.hpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/boost/thread/win32/thread_data.hpp b/include/boost/thread/win32/thread_data.hpp index 1a6a1e03..023c95b4 100644 --- a/include/boost/thread/win32/thread_data.hpp +++ b/include/boost/thread/win32/thread_data.hpp @@ -144,6 +144,11 @@ namespace boost start(0),milliseconds(~uintmax_t(0)),relative(true) {} }; + + unsigned long pin_to_zero(long value) + { + return (value<0)?0u:(unsigned long)value; + } } namespace this_thread @@ -163,7 +168,7 @@ namespace boost template inline void sleep(TimeDuration const& rel_time) { - interruptible_wait(static_cast(rel_time.total_milliseconds())); + interruptible_wait(detail::pin_to_zero(rel_time.total_milliseconds())); } inline void sleep(system_time const& abs_time) {