pal/hermit: correctly round up microseconds in Thread::sleep
by mkroening · Pull Request #129588 · rust-lang/rust (original) (raw)
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation8 Commits2 Checks6 Files changed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
Signed-off-by: Martin Kröning martin.kroening@eonerc.rwth-aachen.de
Operating System: Hermit
Status: Awaiting review from the assignee but also interested parties.
Relevant to the library team, which will review and decide on the PR/issue.
labels
I assume hermit here is assessed as not having to do the "repeatedly call the underlying sleep fn" thing because it has 64-bit usleep?
What if Duration::as_micros
returns a u128 greater than u64::MAX
?
granted, perhaps sleeping accuracy over... uh, would it be... 500,000 years?... is not a concern.
...actually, it IS a little bit of a concern: if someone inputs a really absurd Duration
, the as
conversion is not saturating, it is truncating-to-bits, thus someone can request to sleep until an Age has came and went but actually wake up 0 seconds later. We should first at least use u128::min(u64::MAX as u128, micros)
That is still only relevant to vampires writing Rust code to manage their wakeup alarms for torpor, but can you imagine how cranky someone would be if they woke up a hundred thousand years early?
Probably we should respec Duration in such a way that people don't have to worry about this absurdity, or introduce a new type and make thread::sleep
take a generic, but until then...
Signed-off-by: Martin Kröning martin.kroening@eonerc.rwth-aachen.de
Thanks for the quick review!
I pushed a commit to saturate the conversion. :)
Cool, thanks!
@bors r+ rollup
📌 Commit edeefc5 has been approved by workingjubilee
It is now in the queue for this repository.
bors added S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
and removed S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
labels
bors added a commit to rust-lang-ci/rust that referenced this pull request
…iaskrgr
Rollup of 7 pull requests
Successful merges:
- rust-lang#129190 (Add f16 and f128 to tests/ui/consts/const-float-bits-conv.rs)
- rust-lang#129377 (Add implementations for
unbounded_shl
/unbounded_shr
) - rust-lang#129539 (link to Future::poll from the Poll docs)
- rust-lang#129588 (pal/hermit: correctly round up microseconds in
Thread::sleep
) - rust-lang#129592 (Remove cfg(test) from library/core)
- rust-lang#129597 (mv
build_reduced_graph_for_external_crate_res
into Resolver) - rust-lang#129600 (Tie
impl_trait_overcaptures
lint to Rust 2024)
r? @ghost
@rustbot
modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request
…iaskrgr
Rollup of 7 pull requests
Successful merges:
- rust-lang#129190 (Add f16 and f128 to tests/ui/consts/const-float-bits-conv.rs)
- rust-lang#129377 (Add implementations for
unbounded_shl
/unbounded_shr
) - rust-lang#129539 (link to Future::poll from the Poll docs)
- rust-lang#129588 (pal/hermit: correctly round up microseconds in
Thread::sleep
) - rust-lang#129592 (Remove cfg(test) from library/core)
- rust-lang#129597 (mv
build_reduced_graph_for_external_crate_res
into Resolver) - rust-lang#129600 (Tie
impl_trait_overcaptures
lint to Rust 2024)
r? @ghost
@rustbot
modify labels: rollup
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request
Rollup merge of rust-lang#129588 - hermit-os:sleep-micros, r=workingjubilee
pal/hermit: correctly round up microseconds in Thread::sleep
This fixes the Hermit-related part of rust-lang#129212 and thus the whole issue, since ESP-IDF is already fixed, as far as I understand.
Fixes rust-lang#129212
r? @workingjubilee
CC: @stlankes
Labels
Operating System: Hermit
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Relevant to the library team, which will review and decide on the PR/issue.