time: add sleep
clock_nanosleep with EINTR restart from the kernel remainder.
This commit is contained in:
@@ -157,3 +157,12 @@ import time;
|
||||
assert(!(time.compare(a, b) != -1i8));
|
||||
assert(!(time.compare(b, a) != 1i8));
|
||||
};
|
||||
|
||||
@test fn sleepmonotonic() void = {
|
||||
let before: time.instant = time.now(time.clock.monotonic);
|
||||
time.sleep((5i64 * (time.millisecond: i64)): time.duration,
|
||||
time.clock.monotonic);
|
||||
let after: time.instant = time.now(time.clock.monotonic);
|
||||
let elapsed: i64 = time.diff(before, after): i64;
|
||||
assert(!(elapsed < 5i64 * (time.millisecond: i64)));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user