-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
std::thread::yield_now()
example is lacking.
#134723
Comments
It should not be used to create spin loops, no one should ever create spinloops when an OS scheduler is present |
You could consider a CAS loop to be a spin loop. Also I don't think that that's true, an approach to this is to spin lock with Spin locks are used sometimes in userland code in some apps like game engines. |
You might be thinking of
Does waitonaddress do priority inheritance? On linux futexes can opt in/out of PI. Anyway, even if that's an issue it seems like a highly specific reason that doesn't seem appropriate for a code example. We do have uses of rust/library/std/src/sys/pal/windows/fs/remove_dir_all.rs Lines 153 to 172 in a92c3cf
|
Location
rust/library/std/src/thread/mod.rs:755
Summary
It's not great, ideally it should show a mostly real use case.
It should maybe hint that this should not be used directly to create spin loops without first considering
std::hint::spin_loop
The text was updated successfully, but these errors were encountered: