File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 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> {
767767 // > through this reference must obviously happened before), and an
768768 // > "acquire" operation before deleting the object.
769769 //
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+ //
770780 // [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)
771782 atomic:: fence ( Acquire ) ;
772783
773784 unsafe {
You can’t perform that action at this time.
0 commit comments