Boost logo

Boost :

Subject: Re: [boost] [thread] sleep() with time_duration?
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2008-11-14 07:29:03

----- Original Message -----
From: "Boris" <boriss_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Friday, November 14, 2008 11:38 AM
Subject: [boost] [thread] sleep() with time_duration?

> If I want a thread to sleep for five seconds the shortest code I could
> come up with is:
> boost::system_time time = boost::get_system_time();
> time += boost::posix_time::seconds(5);
> boost::thread::sleep(time);
> 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));
> This would also be consistent with the deadline_timer in Boost.Asio whose
> constructor accepts both a time and a time_duration.


I found your reques inline with the current proposal n2497 contains already
this overloading
    void sleep(const system_time& abs_t);
    template <class Duration>
        void sleep(const Duration& rel_t);

There is also a more recent proposal N2651-A Foundation to Sleep On- Clocks,
Points in Time, and Time Durations
In it we found a proposal to update the thread library rename the sleep

    The current time-related threading API is adapted to this proposal. An
emphasis is put on ease of use, safety, efficiency, and durability with
respect to advancing technology over time.
    Summary of changes:
    The parameters of the time-related functions have been modified to match
the time API in this proposal.
        sleep(rel_time) has been renamed to sleep_for(rel_time).
        sleep(abs_time) has been renamed to sleep_until(abs_time).

Particularly I prefer this renamming, but for compatibility purpose bouth
shoul be implemented.



Boost list run by bdawes at, gregod at, cpdaniel at, john at