summaryrefslogtreecommitdiffstats
path: root/tokio/src/sync/oneshot.rs
diff options
context:
space:
mode:
authorCarl Lerche <me@carllerche.com>2020-03-26 12:23:12 -0700
committerGitHub <noreply@github.com>2020-03-26 12:23:12 -0700
commit1cb1e291c10adf6b4e530cb1475b95ba10fa615f (patch)
treeaabaebe663e2647fb72cb609d1486adcde0c4cc4 /tokio/src/sync/oneshot.rs
parent186196b911bb7cbbd67e74b4ef051d3daf2d64c1 (diff)
rt: track loom changes + tweak queue (#2315)
Loom is having a big refresh to improve performance and tighten up the concurrency model. This diff tracks those changes. Included in the changes is the removal of `CausalCell` deferred checks. This is due to it technically being undefined behavior in the C++11 memory model. To address this, the work-stealing queue is updated to avoid needing this behavior. This is done by limiting the queue to have one concurrent stealer.
Diffstat (limited to 'tokio/src/sync/oneshot.rs')
-rw-r--r--tokio/src/sync/oneshot.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/tokio/src/sync/oneshot.rs b/tokio/src/sync/oneshot.rs
index 163a708d..644832b9 100644
--- a/tokio/src/sync/oneshot.rs
+++ b/tokio/src/sync/oneshot.rs
@@ -2,7 +2,7 @@
//! A channel for sending a single message between asynchronous tasks.
-use crate::loom::cell::CausalCell;
+use crate::loom::cell::UnsafeCell;
use crate::loom::sync::atomic::AtomicUsize;
use crate::loom::sync::Arc;
@@ -81,13 +81,13 @@ struct Inner<T> {
/// The value. This is set by `Sender` and read by `Receiver`. The state of
/// the cell is tracked by `state`.
- value: CausalCell<Option<T>>,
+ value: UnsafeCell<Option<T>>,
/// The task to notify when the receiver drops without consuming the value.
- tx_task: CausalCell<MaybeUninit<Waker>>,
+ tx_task: UnsafeCell<MaybeUninit<Waker>>,
/// The task to notify when the value is sent.
- rx_task: CausalCell<MaybeUninit<Waker>>,
+ rx_task: UnsafeCell<MaybeUninit<Waker>>,
}
#[derive(Clone, Copy)]
@@ -127,9 +127,9 @@ pub fn channel<T>() -> (Sender<T>, Receiver<T>) {
#[allow(deprecated)]
let inner = Arc::new(Inner {
state: AtomicUsize::new(State::new().as_usize()),
- value: CausalCell::new(None),
- tx_task: CausalCell::new(MaybeUninit::uninit()),
- rx_task: CausalCell::new(MaybeUninit::uninit()),
+ value: UnsafeCell::new(None),
+ tx_task: UnsafeCell::new(MaybeUninit::uninit()),
+ rx_task: UnsafeCell::new(MaybeUninit::uninit()),
});
let tx = Sender {
@@ -675,7 +675,7 @@ unsafe impl<T: Send> Sync for Inner<T> {}
impl<T> Drop for Inner<T> {
fn drop(&mut self) {
- let state = State(*self.state.get_mut());
+ let state = State(self.state.with_mut(|v| *v));
if state.is_rx_task_set() {
unsafe {