diff --git a/crates/renderer/src/util.rs b/crates/renderer/src/util.rs index 1183bfc..08d9982 100644 --- a/crates/renderer/src/util.rs +++ b/crates/renderer/src/util.rs @@ -521,6 +521,29 @@ impl<'a> Iterator for ChunkedBitIter<'a> { } } +pub struct RawMutexGuard<'a, T> { + pub(crate) mutex: &'a parking_lot::RawMutex, + pub(crate) value: &'a T, + pub(crate) _pd: std::marker::PhantomData<&'a ()>, +} + +impl<'a, T> std::ops::Deref for RawMutexGuard<'a, T> { + type Target = T; + + fn deref(&self) -> &Self::Target { + self.value + } +} + +impl Drop for RawMutexGuard<'_, T> { + fn drop(&mut self) { + use parking_lot::lock_api::RawMutex; + unsafe { + self.mutex.unlock(); + } + } +} + pub struct CStringList { pub strings: Box<[*const i8]>, bytes: Box<[u8]>,