Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/atom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ impl<Static> Drop for Atom<Static> {

// Out of line to guide inlining.
fn drop_slow<Static>(this: &mut Atom<Static>) {
DYNAMIC_SET
// We temporarily store the string in the stack to drop after releasing the lock
let _removed = DYNAMIC_SET
.lock()
.remove(this.unsafe_data.get() as *mut Entry);
}
Expand Down
9 changes: 4 additions & 5 deletions src/dynamic_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl Set {
ptr
}

pub(crate) fn remove(&mut self, ptr: *mut Entry) {
pub(crate) fn remove(&mut self, ptr: *mut Entry) -> Option<Box<Entry>> {
let bucket_index = {
let value: &Entry = unsafe { &*ptr };
debug_assert!(value.ref_count.load(SeqCst) == 0);
Expand All @@ -97,12 +97,11 @@ impl Set {
while let Some(entry_ptr) = current.as_mut() {
let entry_ptr: *mut Entry = &mut **entry_ptr;
if entry_ptr == ptr {
mem::drop(mem::replace(current, unsafe {
(*entry_ptr).next_in_bucket.take()
}));
break;
return mem::replace(current, unsafe { (*entry_ptr).next_in_bucket.take() });
}
current = unsafe { &mut (*entry_ptr).next_in_bucket };
}

None
}
}