Skip to content

Commit

Permalink
Revise the atomic ordering on refcounts
Browse files Browse the repository at this point in the history
  • Loading branch information
kvark committed Jun 27, 2020
1 parent e3280aa commit df49f5b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions wgpu-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl RefCount {
/// logic. To use this safely from outside of `Drop::drop`, the calling function must move
/// `Self` into a `ManuallyDrop`.
unsafe fn rich_drop_inner(&mut self) -> bool {
if self.0.as_ref().fetch_sub(1, Ordering::Relaxed) == 1 {
if self.0.as_ref().fetch_sub(1, Ordering::AcqRel) == 1 {
let _ = Box::from_raw(self.0.as_ptr());
true
} else {
Expand All @@ -100,7 +100,7 @@ impl RefCount {

impl Clone for RefCount {
fn clone(&self) -> Self {
let old_size = unsafe { self.0.as_ref() }.fetch_add(1, Ordering::Relaxed);
let old_size = unsafe { self.0.as_ref() }.fetch_add(1, Ordering::Release);
assert!(old_size < Self::MAX);
RefCount(self.0)
}
Expand Down Expand Up @@ -159,7 +159,7 @@ impl MultiRefCount {
}

fn dec(&self) -> Option<RefCount> {
match unsafe { self.0.as_ref() }.fetch_sub(1, Ordering::Release) {
match unsafe { self.0.as_ref() }.fetch_sub(1, Ordering::AcqRel) {
0 => unreachable!(),
1 => Some(self.add_ref()),
_ => None,
Expand Down

0 comments on commit df49f5b

Please sign in to comment.