Boost logo

Boost :

Subject: Re: [boost] [thread] Timed waits in Boost.Thread potentiallyfundamentally broken on Windows (possibly rest of Boost too)
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2015-01-25 05:24:17


Le 24/01/15 20:56, Niall Douglas a écrit :
> On 24 Jan 2015 at 21:29, Andrey Semashev wrote:
>
>> And there's another consideration. Waitable timers are useful for
>> absolute waits. For relative waits I would still like Boost.Thread to
>> use relative system waits. The reason is that relative waits do not
>> react to system time shifts and do not require a waitable timer kernel
>> object.
> This is interesting actually. The win32 interruptible_wait() and
> uninterruptible_wait() functions consume a detail::timeout which is
> capable of transferring either relative or absolute timeout. However
> condition_variable timed wait and thread timed join never calls with
> anything but an absolute deadline timeout, and converts all relative
> to absolute. Oddly enough this_thread::sleep_until seems to convert
> its absolute timeout to a relative one, and thunks through
> this_thread::sleep_for, so here all absolutes are converted to
> relative.
>
> So we have the odd situation that condition_variable and thread join
> are always implemented as absolute timeouts, while thread sleep is
> always implemented as relative timeouts. I also see that timed mutex
> always converts absolute to relative too on win32.
>
> Some of this isn't win32 specific either. I can see some code there
> which looks like these are decisions being made by upper layers of
> code and so would affect POSIX as well.
>
> I've added this issue as
> https://svn.boost.org/trac/boost/ticket/10967.
>
> Some references to code:
>
> Always uses absolute:
> https://github.com/boostorg/thread/blob/develop/include/boost/thread/win32/condition_variable.hpp#L92
>
> Always uses relative:
> https://github.com/boostorg/thread/blob/develop/include/boost/thread/win32/basic_timed_mutex.hpp#L190
>
> Always uses relative:
> https://github.com/boostorg/thread/blob/develop/include/boost/thread/v2/thread.hpp#L60
>
> Always uses absolute:
> https://github.com/boostorg/thread/blob/develop/include/boost/thread/detail/thread.hpp#L551
>
>
Thanks Niall for this report.

As you know I'm unable to check on Windows. Please look at the ticket,
I'm here to contribute to fix this incoherences.

Best,
Vicente


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk