We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 982c552 commit 644b445Copy full SHA for 644b445
1 file changed
library/std/src/sys/hermit/mutex.rs
@@ -46,8 +46,17 @@ impl<T> Spinlock<T> {
46
#[inline]
47
fn obtain_lock(&self) {
48
let ticket = self.queue.fetch_add(1, Ordering::SeqCst) + 1;
49
+ let mut counter: u16 = 0;
50
while self.dequeue.load(Ordering::SeqCst) != ticket {
- hint::spin_loop();
51
+ counter = counter + 1;
52
+ if counter < 100 {
53
+ hint::spin_loop();
54
+ } else {
55
+ counter = 0;
56
+ unsafe {
57
+ abi::yield_now();
58
+ }
59
60
}
61
62
0 commit comments