Boost logo

Boost :

Subject: Re: [boost] [thread] sleep() with time_duration?
From: Howard Hinnant (hinnant_at_[hidden])
Date: 2008-11-14 18:51:46


On Nov 14, 2008, at 6:46 PM, vicente.botet wrote:

> ----- Original Message ----- From: "Howard Hinnant" <hinnant_at_[hidden]
> >
> To: <boost_at_[hidden]>
> Sent: Saturday, November 15, 2008 12:29 AM
> Subject: Re: [boost] [thread] sleep() with time_duration?
>
>
>>
>> On Nov 14, 2008, at 5:56 PM, vicente.botet wrote:
>>
>>> ----- Original Message ----- From: "Anthony Williams" <anthony.ajw_at_[hidden]
>>> >
>>> To: <boost_at_[hidden]>
>>> Sent: Friday, November 14, 2008 1:36 PM
>>> Subject: Re: [boost] [thread] sleep() with time_duration?
>>>
>>>
>>>> Boris <boriss_at_[hidden]> writes:
>>>>> It would be nice if it was possible to pass a time_duration
>>>>> object to
>>>>> sleep() directly:
>>>>>
>>>>> boost::thread::sleep(boost::posix_time::seconds(5));
>>>> boost::thread::sleep is only provided for backwards compatibility.
>>>> boost::this_thread::sleep has the absolute time/duration
>>>> overloads you
>>>> desire:
>>>> boost::this_thread::sleep(boost::posix_time::seconds(5));
>>>
>>> The current proposal n2497 contains two overloadings
>>> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2497.html
>>> void boost::this_thread::sleep(const system_time& abs_t);
>>> template <class Duration>
>>> void boost::this_thread::sleep(const Duration& rel_t);
>>>
>>> Boost.Thread contains only the template <class Duration>
>>> void boost::this_thread::sleep(const Duration& rel_t);
>>>
>>> Could you add the other?
>>
>> N2497 was overridden by N2661:
>>
>> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2661.htm#Threads_wording
>>
>> This is all put together in the latest working draft:
>>
>> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2798.pdf
>>
>> namespace std {
>> namespace this_thread {
>>
>> template <class Clock, class Duration>
>> void sleep_until(const chrono::time_point<Clock, Duration>&
>> abs_time);
>> template <class Rep, class Period>
>> void sleep_for(const chrono::duration<Rep, Period>& rel_time);
>>
>> }
>> }
>
> Yes, I know that, see my preceding post.

Ah, sorry 'bout that. You caught me skimming. :-)

> But we don't have yet chrono in boost.

I'm probably skimming too fast again, but just in case you were too,
Beman has this ready to go:

See http://svn.boost.org/svn/boost/sandbox/chrono

>
> Waiting for that maybe Anthony can add this
>
> template <class AbsoluteTime>
> void boost::this_thread::sleep_until(Time& abs_t);
> template <class Duration>
> void boost::this_thread::sleep_for(const Duration& rel_t);

I'll leave it Anthony (of course), but these signatures look overly
generic to me (anything will bind to them).

-Howard


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