Skip to content

Commit

Permalink
Rollup merge of rust-lang#41730 - bholley:arc_comment, r=aturon
Browse files Browse the repository at this point in the history
Document the reasoning for the Acquire/Release handshake when dropping Arcs.

Split out from rust-lang#41714. r? @aturon
  • Loading branch information
frewsxcv committed May 3, 2017
2 parents a7c8bd1 + 7b05b88 commit e20b282
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/liballoc/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,18 @@ unsafe impl<#[may_dangle] T: ?Sized> Drop for Arc<T> {
// > through this reference must obviously happened before), and an
// > "acquire" operation before deleting the object.
//
// In particular, while the contents of an Arc are usually immutable, it's
// possible to have interior writes to something like a Mutex<T>. Since a
// Mutex is not acquired when it is deleted, we can't rely on its
// synchronization logic to make writes in thread A visible to a destructor
// running in thread B.
//
// Also note that the Acquire fence here could probably be replaced with an
// Acquire load, which could improve performance in highly-contended
// situations. See [2].
//
// [1]: (www.boost.org/doc/libs/1_55_0/doc/html/atomic/usage_examples.html)
// [2]: (https://github.com/rust-lang/rust/pull/41714)
atomic::fence(Acquire);

unsafe {
Expand Down

0 comments on commit e20b282

Please sign in to comment.