-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Document when to use std::thread::yield_now vs. std::sync::atomic::spin_loop_hint #55418
Comments
@rust-lang/libs Anyone able to describe the differences and use-cases for these functions? I'd be willing to add docs for this, I just don't know when to use either |
My understanding for these two functions is:
I believe the general wisdom is that on lock contention you |
One use case for |
@frewsxcv Are you still interested in writing docs for this? |
@DevQps I still don't feel confident to write them given my current level of understanding with these APIs. But if you want to try, go for it! |
@frewsxcv I will give it a try! I am sure others will correct me if I write some things that are wrong :) I hope I'll be able to deliver a PR somewhere this week. |
@alexcrichton It seems like you always pop up on my screen when people are talking about technical details so I thought you might be the right man for this question :) When diving into the details of
So basically
Question:
|
@alexcrichton @frewsxcv I did an attempt! I hope it clarifies some things. I didn't edit the |
… r=alexcrichton Updated the documentation of spin_loop and spin_loop_hint # Description - Updated the description of `core::hints::spin_loop` - Updated the description of `core::async::spin_loop_hint` Both documentation is rewritten to better reflect when one should prefer using a busy-wait spin-loop (and the `spin_loop` and `spin_loop_hint` functions) over `yield_now`. It also dives a little bit deeper on what the function actually does. closes rust-lang#55418
… r=alexcrichton Updated the documentation of spin_loop and spin_loop_hint # Description - Updated the description of `core::hints::spin_loop` - Updated the description of `core::async::spin_loop_hint` Both documentation is rewritten to better reflect when one should prefer using a busy-wait spin-loop (and the `spin_loop` and `spin_loop_hint` functions) over `yield_now`. It also dives a little bit deeper on what the function actually does. closes rust-lang#55418
… r=alexcrichton Updated the documentation of spin_loop and spin_loop_hint # Description - Updated the description of `core::hints::spin_loop` - Updated the description of `core::async::spin_loop_hint` Both documentation is rewritten to better reflect when one should prefer using a busy-wait spin-loop (and the `spin_loop` and `spin_loop_hint` functions) over `yield_now`. It also dives a little bit deeper on what the function actually does. closes rust-lang#55418
… r=alexcrichton Updated the documentation of spin_loop and spin_loop_hint # Description - Updated the description of `core::hints::spin_loop` - Updated the description of `core::async::spin_loop_hint` Both documentation is rewritten to better reflect when one should prefer using a busy-wait spin-loop (and the `spin_loop` and `spin_loop_hint` functions) over `yield_now`. It also dives a little bit deeper on what the function actually does. closes rust-lang#55418
On the surface, these functions seem very similar. When is it appropriate to use one vs. the other?
The text was updated successfully, but these errors were encountered: