mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-15 00:00:15 +02:00
sync: use spin_loop_hint instead of yield_now in mpsc (#4037)
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
use crate::loom::cell::UnsafeCell;
|
||||
use crate::loom::sync::atomic::{AtomicPtr, AtomicUsize};
|
||||
use crate::loom::thread;
|
||||
|
||||
use std::mem::MaybeUninit;
|
||||
use std::ops;
|
||||
@@ -344,8 +343,13 @@ impl<T> Block<T> {
|
||||
Err(curr) => curr,
|
||||
};
|
||||
|
||||
// When running outside of loom, this calls `spin_loop_hint`.
|
||||
thread::yield_now();
|
||||
#[cfg(all(test, loom))]
|
||||
crate::loom::thread::yield_now();
|
||||
|
||||
// TODO: once we bump MSRV to 1.49+, use `hint::spin_loop` instead.
|
||||
#[cfg(not(all(test, loom)))]
|
||||
#[allow(deprecated)]
|
||||
std::sync::atomic::spin_loop_hint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user