-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement the
std::hint
module (#78)
The only thing we actually care about here is `hint::spin_loop`, which we just treat the same way as `yield_now`. Part of #75.
- Loading branch information
1 parent
bae3598
commit 49e4fcc
Showing
2 changed files
with
15 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
//! Shuttle's implementation of [`std::hint`]. | ||
pub use std::hint::*; | ||
|
||
use crate::thread; | ||
|
||
/// Emits a machine instruction to signal the processor that it is running in a busy-wait spin-loop | ||
/// (“spin lock”). | ||
pub fn spin_loop() { | ||
// Probably not necessary, but let's emit it just in case | ||
std::hint::spin_loop(); | ||
|
||
thread::yield_now(); | ||
} |
This file contains 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