diff options
| author | Jonas Schievink <jonasschievink@gmail.com> | 2020-10-24 14:11:56 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-24 14:11:56 +0200 |
| commit | 8e756698dfc6219a0acf511a9ebb9e6063bdadc2 (patch) | |
| tree | 39ef8e83a581dbbd90951683215bd1dc9f576e17 | |
| parent | 2e8a54af60df63034e41359acfc923e5c5769a91 (diff) | |
| parent | 929f80ece9d8875ef38dc45b4cfe372f263bc7c2 (diff) | |
Rollup merge of #76649 - nicbn:arc-spin-loop-hint, r=m-ou-se
Add a spin loop hint for Arc::downgrade Adds `hint::spin_loop()` to the case where `Arc::downgrade` spins.
| -rw-r--r-- | library/alloc/src/lib.rs | 1 | ||||
| -rw-r--r-- | library/alloc/src/sync.rs | 2 |
2 files changed, 3 insertions, 0 deletions
diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index b69e19072af..c039be8f67c 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -118,6 +118,7 @@ #![feature(raw_ref_op)] #![feature(rustc_attrs)] #![feature(receiver_trait)] +#![feature(renamed_spin_loop)] #![feature(min_specialization)] #![feature(slice_ptr_get)] #![feature(slice_ptr_len)] diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index 3a83aa7cbe5..cd18535b069 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -10,6 +10,7 @@ use core::cmp::Ordering; use core::convert::{From, TryFrom}; use core::fmt; use core::hash::{Hash, Hasher}; +use core::hint; use core::intrinsics::abort; use core::iter; use core::marker::{PhantomData, Unpin, Unsize}; @@ -764,6 +765,7 @@ impl<T: ?Sized> Arc<T> { loop { // check if the weak counter is currently "locked"; if so, spin. if cur == usize::MAX { + hint::spin_loop(); cur = this.inner().weak.load(Relaxed); continue; } |
