Rust nightly update - turn_lock

This commit is contained in:
Guillume DIDIER 2021-06-10 11:23:13 +02:00
parent 0531f8d083
commit 9c569fb7ec

View File

@ -1,7 +1,8 @@
use std::cell::UnsafeCell; use std::cell::UnsafeCell;
use std::hint::spin_loop;
use std::marker::PhantomData; use std::marker::PhantomData;
use std::ops::{Deref, DerefMut}; use std::ops::{Deref, DerefMut};
use std::sync::atomic::{spin_loop_hint, AtomicUsize, Ordering}; use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc; use std::sync::Arc;
// FIXME There may be significant unsafety if wait is called twice ? // FIXME There may be significant unsafety if wait is called twice ?
@ -33,7 +34,7 @@ impl RawTurnLock {
pub unsafe fn wait(&self, turn: usize) { pub unsafe fn wait(&self, turn: usize) {
let mut current = self.turn.load(Ordering::Acquire); let mut current = self.turn.load(Ordering::Acquire);
while current < self.num_turns && current != turn { while current < self.num_turns && current != turn {
spin_loop_hint(); spin_loop();
current = self.turn.load(Ordering::Acquire); current = self.turn.load(Ordering::Acquire);
} }
if current >= self.num_turns { if current >= self.num_turns {