Skip to content

Commit fdb5fc1

Browse files
committed
pal/hermit: correctly round up microseconds in Thread::sleep
Signed-off-by: Martin Kröning <[email protected]>
1 parent 4de4deb commit fdb5fc1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Diff for: std/src/sys/pal/hermit/thread.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,10 @@ impl Thread {
7777

7878
#[inline]
7979
pub fn sleep(dur: Duration) {
80+
let micros = dur.as_micros() + if dur.subsec_nanos() % 1_000 > 0 { 1 } else { 0 };
81+
8082
unsafe {
81-
hermit_abi::usleep(dur.as_micros() as u64);
83+
hermit_abi::usleep(micros as u64);
8284
}
8385
}
8486

0 commit comments

Comments
 (0)