Skip to content

Commit 559d674

Browse files
committed
array_queue_mpsc: Spin less when reading slot
1 parent 64ed7a6 commit 559d674

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/crossbeam/array_queue_mpsc.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ impl<T> ArrayQueueMpsc<T> {
249249

250250
if tail_cached == head {
251251
if SPIN {
252-
std::hint::spin_loop();
252+
core::hint::spin_loop();
253253
let tail = if _final_check {
254254
self.sender.load(Ordering::SeqCst) as u32
255255
} else {
@@ -273,14 +273,13 @@ impl<T> ArrayQueueMpsc<T> {
273273
debug_assert!(index < self.buffer.len());
274274
let slot = unsafe { self.buffer.get_unchecked(index) };
275275
// Wait for stamp update
276-
let backoff = Backoff::new();
277276
let target_stamp = (head as usize).wrapping_add(1);
278277
loop {
279278
let stamp = slot.stamp.load(Ordering::Acquire);
280279
if stamp == target_stamp {
281280
break;
282281
}
283-
backoff.snooze();
282+
core::hint::spin_loop();
284283
}
285284
// Update head
286285
let new_head = if index + 1 < self.buffer.len() {

0 commit comments

Comments
 (0)