Skip to content

Commit 929f80e

Browse files
committed
Add a spin loop hint for Arc::downgrade
1 parent 07a63e6 commit 929f80e

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

Diff for: library/alloc/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@
118118
#![feature(raw_ref_op)]
119119
#![feature(rustc_attrs)]
120120
#![feature(receiver_trait)]
121+
#![feature(renamed_spin_loop)]
121122
#![feature(min_specialization)]
122123
#![feature(slice_ptr_get)]
123124
#![feature(slice_ptr_len)]

Diff for: library/alloc/src/sync.rs

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use core::cmp::Ordering;
1010
use core::convert::{From, TryFrom};
1111
use core::fmt;
1212
use core::hash::{Hash, Hasher};
13+
use core::hint;
1314
use core::intrinsics::abort;
1415
use core::iter;
1516
use core::marker::{PhantomData, Unpin, Unsize};
@@ -764,6 +765,7 @@ impl<T: ?Sized> Arc<T> {
764765
loop {
765766
// check if the weak counter is currently "locked"; if so, spin.
766767
if cur == usize::MAX {
768+
hint::spin_loop();
767769
cur = this.inner().weak.load(Relaxed);
768770
continue;
769771
}

0 commit comments

Comments
 (0)