mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-27 00:00:12 +02:00
sync: track loom changes (#1405)
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ fn smoke() {
|
||||
}
|
||||
None => {
|
||||
debug!(" + pop() -> None");
|
||||
loom::yield_now();
|
||||
thread::yield_now();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user