util: rawmutexguard: MutexGuard for RawMutex
This commit is contained in:
parent
5593abc3b5
commit
75e75ec706
|
@ -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 struct CStringList {
|
||||||
pub strings: Box<[*const i8]>,
|
pub strings: Box<[*const i8]>,
|
||||||
bytes: Box<[u8]>,
|
bytes: Box<[u8]>,
|
||||||
|
|
Loading…
Reference in a new issue