sync: track loom changes (#1405)

This commit is contained in:
Carl Lerche
2019-08-07 15:38:34 -07:00
committed by GitHub
parent 0a05332648
commit 23c380a78f
5 changed files with 15 additions and 13 deletions
+4 -2
View File
@@ -31,6 +31,8 @@ pub(crate) mod sync {
}
}
pub(crate) fn yield_now() {
::std::sync::atomic::spin_loop_hint();
pub(crate) mod thread {
pub(crate) fn yield_now() {
::std::sync::atomic::spin_loop_hint();
}
}
+2 -2
View File
@@ -1,7 +1,7 @@
use crate::loom::{
self,
sync::atomic::{AtomicPtr, AtomicUsize},
sync::CausalCell,
thread,
};
use std::mem::{self, ManuallyDrop};
use std::ops;
@@ -344,7 +344,7 @@ impl<T> Block<T> {
};
// When running outside of loom, this calls `spin_loop_hint`.
loom::yield_now();
thread::yield_now();
}
}
}
+4 -4
View File
@@ -2,8 +2,8 @@
use super::block::{self, Block};
use crate::loom::{
self,
sync::atomic::{AtomicPtr, AtomicUsize},
thread,
};
use std::fmt;
use std::ptr::NonNull;
@@ -163,7 +163,7 @@ impl<T> Tx<T> {
block_ptr = next_block.as_ptr();
loom::yield_now();
thread::yield_now();
}
}
@@ -270,7 +270,7 @@ impl<T> Rx<T> {
self.head = next_block;
loom::yield_now();
thread::yield_now();
}
}
@@ -308,7 +308,7 @@ impl<T> Rx<T> {
tx.reclaim_block(block);
}
loom::yield_now();
thread::yield_now();
}
}
+4 -4
View File
@@ -14,7 +14,7 @@ use crate::loom::{
atomic::{AtomicPtr, AtomicUsize},
CausalCell,
},
yield_now,
thread,
};
use std::fmt;
@@ -432,7 +432,7 @@ impl Semaphore {
if curr.has_waiter(&self.stub) {
// Inconsistent
debug!(" + pop; inconsistent 1");
yield_now();
thread::yield_now();
continue 'outer;
}
@@ -479,7 +479,7 @@ impl Semaphore {
if tail != head {
// Inconsistent
debug!(" + pop; inconsistent 2");
yield_now();
thread::yield_now();
continue 'outer;
}
@@ -495,7 +495,7 @@ impl Semaphore {
// Inconsistent state, loop
debug!(" + pop; inconsistent 3");
yield_now();
thread::yield_now();
}
}
}
+1 -1
View File
@@ -63,7 +63,7 @@ fn smoke() {
}
None => {
debug!(" + pop() -> None");
loom::yield_now();
thread::yield_now();
}
}
}