Skip to content

Commit b00d983

Browse files
committed
pass check-loom
1 parent fac5348 commit b00d983

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

homework/src/arc.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,13 @@ impl<T> Drop for Arc<T> {
444444
/// drop(foo2); // Prints "dropped!"
445445
/// ```
446446
fn drop(&mut self) {
447-
self.inner().count.fetch_sub(1, Ordering::AcqRel);
448-
if self.inner().count.load(Ordering::Acquire) == 0 {
447+
// TODO: reason not known yet
448+
// The following code does not work in check-loom mode.
449+
// self.inner().count.fetch_sub(1, Ordering::AcqRel);
450+
// if self.inner().count.load(Ordering::Acquire) == 0 {
451+
452+
// pass the test in check-loom mode
453+
if self.inner().count.fetch_sub(1, Ordering::AcqRel) == 1 {
449454
unsafe {
450455
// drop the inner value
451456
drop(Box::from_raw(self.ptr.as_ptr()));

0 commit comments

Comments
 (0)