Skip to content

Commit 5628a23

Browse files
committed
samples: bench: Check for Arc leaks
After running the work queue benchmarks, ensure that we haven't leaked any Arcs. Signed-off-by: David Brown <[email protected]>
1 parent b7a5449 commit 5628a23

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

samples/bench/src/lib.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -619,15 +619,16 @@ impl Simple {
619619
);
620620

621621
// Before we go away, make sure that there aren't any leaked workers.
622-
/*
623622
let mut locked = main.action().locked.lock().unwrap();
624623
while let Some(other) = locked.works.pop_front() {
625-
// Portable atomic's Arc seems to be a problem here.
626-
let other = unsafe { Pin::into_inner_unchecked(other) };
624+
let other = Pin::into_inner(other);
627625
assert_eq!(Arc::strong_count(&other), 1);
628-
// printkln!("Child: {} refs", Arc::strong_count(&other));
629626
}
630-
*/
627+
drop(locked);
628+
629+
// And nothing has leaked main, either.
630+
let main = Pin::into_inner(main);
631+
assert_eq!(Arc::strong_count(&main), 1);
631632
}
632633
}
633634

0 commit comments

Comments
 (0)