Opened 13 years ago

Closed 12 years ago

#3179 closed Bugs (fixed)

Sleep with local_time

Reported by: anonymous Owned by: Anthony Williams
Milestone: Boost 1.40.0 Component: thread
Version: Boost 1.39.0 Severity: Problem
Keywords: sleep time Cc:

Description

When calling sleep with an absolute time, it sleeps about two hours instead of one second in code similar to the below example.

ptime now = second_clock::local_time(); this_thread::sleep( now + second(1) )

Change History (4)

in reply to:  description comment:1 by anonymous, 13 years ago

Replying to anonymous:

When calling sleep with an absolute time, it sleeps about two hours instead of one second in code similar to the below example.

ptime now = second_clock::local_time(); this_thread::sleep( now + second(1) )

After a lot of headache I think that might is due to a missmatch with utc and local time. Please make it possible to sleep until a "local time" (local time zone) and write something about it in the documentations, I haven't found anything special about which type of time should be used.

comment:2 by viboes, 13 years ago

The this_thread::sleep prototype is

    template<typename TimeDuration>
    void sleep(TimeDuration const& rel_time);

The TimeDuration you can pass as parameter must be one for which system_time+TimeDuration is defined.

You are right that this should be documented. BTW the interface for thread::sleep is

    void thread::sleep(system_time const& abs_time);

Anthony, to be coherent, shouldn't you add the absolute time interface on the namespace this_thread? Waiting fro Boost.Chrono, what about adding

void sleep(system_time const& abs_time);
void sleep_until(system_time const& abs_time);
template <class TimeDuration>
void sleep_for(TimeDuration const& rel_time);

comment:3 by viboes, 12 years ago

This is already implemented, but the documentation is not updated.

comment:4 by Anthony Williams, 12 years ago

Resolution: fixed
Status: newclosed

Updated documentation on trunk.

Note: See TracTickets for help on using tickets.