util: rawmutexguard: MutexGuard for RawMutex

This commit is contained in:
Janis 2025-01-19 18:42:45 +01:00
parent 5593abc3b5
commit 75e75ec706

View file

@ -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<T> 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]>,