summaryrefslogtreecommitdiff
path: root/src/collection/owned.rs
diff options
context:
space:
mode:
authorMica White <botahamec@outlook.com>2026-03-14 20:37:26 -0400
committerMica White <botahamec@outlook.com>2026-03-14 20:37:26 -0400
commitd9095d8fce59714f75019ecf68911d9931a1af15 (patch)
tree7f466b2d61b437c5b6721aa030a7518cf7e690eb /src/collection/owned.rs
parentfbdfc775bd1642a469f8a3fa0aa9beb91ca760d6 (diff)
Basic scoped lock and guard implementations
Diffstat (limited to 'src/collection/owned.rs')
-rwxr-xr-xsrc/collection/owned.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/collection/owned.rs b/src/collection/owned.rs
index 2172b96..516f1ea 100755
--- a/src/collection/owned.rs
+++ b/src/collection/owned.rs
@@ -647,9 +647,21 @@ impl<L: OwnedLockable> OwnedLockCollection<L>
where
for<'a> &'a L: IntoIterator,
{
- pub fn locking_iter(&self, key: ThreadKey) -> LockingIterator<<&L as IntoIterator>::IntoIter> {
+ pub fn locking_iter(
+ &self,
+ key: ThreadKey,
+ ) -> LockingIterator<<&L as IntoIterator>::IntoIter, ThreadKey> {
LockingIterator::new(key, (&self.child).into_iter())
}
+
+ pub fn scoped_locking_iter<Key: Keyable, R>(
+ &self,
+ key: Key,
+ f: impl FnOnce(&mut LockingIterator<<&L as IntoIterator>::IntoIter, Key>) -> R,
+ ) -> R {
+ let mut iterator = LockingIterator::new(key, (&self.child).into_iter());
+ f(&mut iterator)
+ }
}
#[cfg(test)]