File tree 1 file changed +11
-0
lines changed
1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -767,7 +767,18 @@ unsafe impl<#[may_dangle] T: ?Sized> Drop for Arc<T> {
767
767
// > through this reference must obviously happened before), and an
768
768
// > "acquire" operation before deleting the object.
769
769
//
770
+ // In particular, while the contents of an Arc are usually immutable, it's
771
+ // possible to have interior writes to something like a Mutex<T>. Since a
772
+ // Mutex is not acquired when it is deleted, we can't rely on its
773
+ // synchronization logic to make writes in thread A visible to a destructor
774
+ // running in thread B.
775
+ //
776
+ // Also note that the Acquire fence here could probably be replaced with an
777
+ // Acquire load, which could improve performance in highly-contended
778
+ // situations. See [2].
779
+ //
770
780
// [1]: (www.boost.org/doc/libs/1_55_0/doc/html/atomic/usage_examples.html)
781
+ // [2]: (https://github.com/rust-lang/rust/pull/41714)
771
782
atomic:: fence ( Acquire ) ;
772
783
773
784
unsafe {
You can’t perform that action at this time.
0 commit comments