aboutsummaryrefslogtreecommitdiff
path: root/src/once.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/once.rs')
-rw-r--r--src/once.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/once.rs b/src/once.rs
index f458c9c..6b91ac4 100644
--- a/src/once.rs
+++ b/src/once.rs
@@ -258,11 +258,11 @@ impl Once {
// Park our thread until we are woken up by the thread that owns the
// lock.
+ let addr = self as *const _ as usize;
+ let validate = || self.0.load(Ordering::Relaxed) == LOCKED_BIT | PARKED_BIT;
+ let before_sleep = || {};
+ let timed_out = |_, _| unreachable!();
unsafe {
- let addr = self as *const _ as usize;
- let validate = || self.0.load(Ordering::Relaxed) == LOCKED_BIT | PARKED_BIT;
- let before_sleep = || {};
- let timed_out = |_, _| unreachable!();
parking_lot_core::park(
addr,
validate,
@@ -285,8 +285,8 @@ impl Once {
let once = self.0;
let state = once.0.swap(POISON_BIT, Ordering::Release);
if state & PARKED_BIT != 0 {
+ let addr = once as *const _ as usize;
unsafe {
- let addr = once as *const _ as usize;
parking_lot_core::unpark_all(addr, DEFAULT_UNPARK_TOKEN);
}
}
@@ -307,8 +307,8 @@ impl Once {
// Now unlock the state, set the done bit and unpark all threads
let state = self.0.swap(DONE_BIT, Ordering::Release);
if state & PARKED_BIT != 0 {
+ let addr = self as *const _ as usize;
unsafe {
- let addr = self as *const _ as usize;
parking_lot_core::unpark_all(addr, DEFAULT_UNPARK_TOKEN);
}
}