summaryrefslogtreecommitdiff
path: root/src/collection
diff options
context:
space:
mode:
authorMica White <botahamec@gmail.com>2024-12-26 11:06:23 -0500
committerMica White <botahamec@gmail.com>2024-12-26 11:26:29 -0500
commit096afea6f13692fddbfad0b07e5377cb2e81dd58 (patch)
tree53c252e3277683e7e8686539fde83e6cc5e1762d /src/collection
parenta060123077b94f61e3d0802a6977ad547276fd1b (diff)
Rename kill to poison
Diffstat (limited to 'src/collection')
-rw-r--r--src/collection/boxed.rs6
-rw-r--r--src/collection/owned.rs4
-rw-r--r--src/collection/ref.rs4
-rw-r--r--src/collection/retry.rs4
-rw-r--r--src/collection/utils.rs4
5 files changed, 12 insertions, 10 deletions
diff --git a/src/collection/boxed.rs b/src/collection/boxed.rs
index 2397bd3..a048d2b 100644
--- a/src/collection/boxed.rs
+++ b/src/collection/boxed.rs
@@ -21,9 +21,9 @@ fn contains_duplicates(l: &[&dyn RawLock]) -> bool {
}
unsafe impl<L: Lockable> RawLock for BoxedLockCollection<L> {
- fn kill(&self) {
+ fn poison(&self) {
for lock in &self.locks {
- lock.kill();
+ lock.poison();
}
}
@@ -196,6 +196,8 @@ impl<L> BoxedLockCollection<L> {
self.locks.clear();
// safety: this was allocated using a box, and is now unique
let boxed: Box<UnsafeCell<L>> = Box::from_raw(self.data.cast_mut());
+ // to prevent a double free
+ std::mem::forget(self);
boxed.into_inner()
}
diff --git a/src/collection/owned.rs b/src/collection/owned.rs
index e4cfe46..59e1ff8 100644
--- a/src/collection/owned.rs
+++ b/src/collection/owned.rs
@@ -14,10 +14,10 @@ fn get_locks<L: Lockable>(data: &L) -> Vec<&dyn RawLock> {
}
unsafe impl<L: Lockable> RawLock for OwnedLockCollection<L> {
- fn kill(&self) {
+ fn poison(&self) {
let locks = get_locks(&self.data);
for lock in locks {
- lock.kill();
+ lock.poison();
}
}
diff --git a/src/collection/ref.rs b/src/collection/ref.rs
index 4fa5485..a9c3579 100644
--- a/src/collection/ref.rs
+++ b/src/collection/ref.rs
@@ -40,9 +40,9 @@ where
}
unsafe impl<L: Lockable> RawLock for RefLockCollection<'_, L> {
- fn kill(&self) {
+ fn poison(&self) {
for lock in &self.locks {
- lock.kill();
+ lock.poison();
}
}
diff --git a/src/collection/retry.rs b/src/collection/retry.rs
index 687c5ec..cb6a1fb 100644
--- a/src/collection/retry.rs
+++ b/src/collection/retry.rs
@@ -36,10 +36,10 @@ fn contains_duplicates<L: Lockable>(data: L) -> bool {
}
unsafe impl<L: Lockable> RawLock for RetryingLockCollection<L> {
- fn kill(&self) {
+ fn poison(&self) {
let locks = get_locks(&self.data);
for lock in locks {
- lock.kill();
+ lock.poison();
}
}
diff --git a/src/collection/utils.rs b/src/collection/utils.rs
index f418386..36b19be 100644
--- a/src/collection/utils.rs
+++ b/src/collection/utils.rs
@@ -96,7 +96,7 @@ pub unsafe fn attempt_to_recover_locks_from_panic(locked: &RefCell<Vec<&dyn RawL
locked_lock.raw_unlock();
}
},
- || locked.borrow().iter().for_each(|l| l.kill()),
+ || locked.borrow().iter().for_each(|l| l.poison()),
)
}
@@ -108,6 +108,6 @@ pub unsafe fn attempt_to_recover_reads_from_panic(locked: &RefCell<Vec<&dyn RawL
locked_lock.raw_unlock_read();
}
},
- || locked.borrow().iter().for_each(|l| l.kill()),
+ || locked.borrow().iter().for_each(|l| l.poison()),
)
}