Subject: Re: [Boost-bugs] [Boost C++ Libraries] #3178: Sleep with negative time
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-02-04 18:13:40
#3178: Sleep with negative time
--------------------------------------------+-------------------------------
Reporter: daniel | Owner: anthonyw
Type: Bugs | Status: new
Milestone: Boost 1.40.0 | Component: thread
Version: Boost 1.39.0 | Severity: Regression
Keywords: thread sleep timespan negative |
--------------------------------------------+-------------------------------
Comment(by marshall):
I've got to concur with the OP (from libs/thread/win32/thread_data.hpp):
{{{
namespace this_thread {
template<typename TimeDuration>
inline void sleep(TimeDuration const& rel_time)
{
interruptible_wait(static_cast<unsigned
long>(rel_time.total_milliseconds()));
}
}
}}}
The problem here is the cast to unsigned long; that turns a small negative
value into a large positive one.
The question is, what should happen? Should the fn return immediately?
Throw an exception?
On the pthread side, the code looks like:
{{{
namespace this_thread {
inline void sleep(TimeDuration const& rel_time)
{
this_thread::sleep(get_system_time()+rel_time);
}
}
}}}
I don't know what happens if you pass a time in the past to sleep here,
but the same questions as to how to handle the error apply.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/3178#comment:2> 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:02 UTC