Add a spin loop hint for Arc::downgrade
This commit is contained in:
parent
07a63e6d1f
commit
929f80ece9
2 changed files with 3 additions and 0 deletions
|
@ -118,6 +118,7 @@
|
||||||
#![feature(raw_ref_op)]
|
#![feature(raw_ref_op)]
|
||||||
#![feature(rustc_attrs)]
|
#![feature(rustc_attrs)]
|
||||||
#![feature(receiver_trait)]
|
#![feature(receiver_trait)]
|
||||||
|
#![feature(renamed_spin_loop)]
|
||||||
#![feature(min_specialization)]
|
#![feature(min_specialization)]
|
||||||
#![feature(slice_ptr_get)]
|
#![feature(slice_ptr_get)]
|
||||||
#![feature(slice_ptr_len)]
|
#![feature(slice_ptr_len)]
|
||||||
|
|
|
@ -10,6 +10,7 @@ use core::cmp::Ordering;
|
||||||
use core::convert::{From, TryFrom};
|
use core::convert::{From, TryFrom};
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
use core::hash::{Hash, Hasher};
|
use core::hash::{Hash, Hasher};
|
||||||
|
use core::hint;
|
||||||
use core::intrinsics::abort;
|
use core::intrinsics::abort;
|
||||||
use core::iter;
|
use core::iter;
|
||||||
use core::marker::{PhantomData, Unpin, Unsize};
|
use core::marker::{PhantomData, Unpin, Unsize};
|
||||||
|
@ -764,6 +765,7 @@ impl<T: ?Sized> Arc<T> {
|
||||||
loop {
|
loop {
|
||||||
// check if the weak counter is currently "locked"; if so, spin.
|
// check if the weak counter is currently "locked"; if so, spin.
|
||||||
if cur == usize::MAX {
|
if cur == usize::MAX {
|
||||||
|
hint::spin_loop();
|
||||||
cur = this.inner().weak.load(Relaxed);
|
cur = this.inner().weak.load(Relaxed);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue