зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1476445
- Use an acquire load for is_unique in servo_arc. r=manishearth
MozReview-Commit-ID: Dv7Rql4KUgr Differential Revision: https://phabricator.services.mozilla.com/D2205 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
d385db1af9
Коммит
6bd85a621e
|
@ -349,15 +349,10 @@ impl<T: ?Sized> Arc<T> {
|
|||
|
||||
#[inline]
|
||||
pub fn is_unique(&self) -> bool {
|
||||
// We can use Relaxed here, but the justification is a bit subtle.
|
||||
// See the extensive discussion in [1] for why this needs to be Acquire.
|
||||
//
|
||||
// The reason to use Acquire would be to synchronize with other threads
|
||||
// that are modifying the refcount with Release, i.e. to ensure that
|
||||
// their writes to memory guarded by this refcount are flushed. However,
|
||||
// we know that threads only modify the contents of the Arc when they
|
||||
// observe the refcount to be 1, and no other thread could observe that
|
||||
// because we're holding one strong reference here.
|
||||
self.inner().count.load(Relaxed) == 1
|
||||
// [1] https://github.com/servo/servo/issues/21186
|
||||
self.inner().count.load(Acquire) == 1
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче