mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-29 00:00:11 +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::cell::UnsafeCell;
|
||||||
use crate::loom::sync::atomic::{AtomicPtr, AtomicUsize};
|
use crate::loom::sync::atomic::{AtomicPtr, AtomicUsize};
|
||||||
use crate::loom::thread;
|
|
||||||
|
|
||||||
use std::mem::MaybeUninit;
|
use std::mem::MaybeUninit;
|
||||||
use std::ops;
|
use std::ops;
|
||||||
@@ -344,8 +343,13 @@ impl<T> Block<T> {
|
|||||||
Err(curr) => curr,
|
Err(curr) => curr,
|
||||||
};
|
};
|
||||||
|
|
||||||
// When running outside of loom, this calls `spin_loop_hint`.
|
#[cfg(all(test, loom))]
|
||||||
thread::yield_now();
|
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