Closed
Description
A sleep_until
method for periodic timing without drifting is needed. In many cases this is much better to use than the sleep
function. The Ada Ravenscar profile even forbids the use of the delay
facility because it is so less predictable, and often leads to broken code. Currently, there is a periodic
method one can use but for more complicated cases one would still need the sleep_until
function.
Sample usage of the hypothetical sleep_until
:
fn periodic(t : Timer) {
let mut next_tick = time::precise_time_ns() / 100_000;
loop {
// .... Tick code
next_tick += 100;
timer.sleep_until(next_tick);
}
}
Wikipedia example of delay causing clock drift http://en.wikibooks.org/wiki/Ada_Style_Guide/Concurrency#Delay_Statements