extern crate parking_lot;
use crate::core::SyncPointBeh;
pub use parking_lot::Mutex;
pub use parking_lot::MutexGuard;
pub use parking_lot::const_mutex;
impl<T> SyncPointBeh for Mutex<T> {
type LockType<'a>
= MutexGuard<'a, T>
where
T: 'a;
type DerefLockType = T;
#[inline]
fn new_lock(&self) -> Self::LockType<'_> {
Mutex::lock(self)
}
#[inline]
#[cfg_attr(docsrs, doc(cfg(feature = "pl")))]
#[cfg(all(feature = "pl", not(feature = "std"), not(feature = "async")))]
fn is_lock(&self) -> bool {
Mutex::is_locked(self)
}
#[inline]
fn try_lock(&self) -> Option<Self::LockType<'_>> {
Mutex::try_lock(self)
}
#[inline]
fn unlock<'a>(&'a self, lock_type: Self::LockType<'a>) {
drop(lock_type)
}
}
#[macro_export]
#[doc(hidden)]
#[cfg(not(any(feature = "std", feature = "async")))]
macro_rules! __sync_beh {
{
#name
} => { "parking_lot" };
{
#new_point<$t: ty : [$t_make:expr]>: $v_point_name:ident
} => {
#[allow(dead_code)]
#[allow(non_upper_case_globals)]
#[allow(non_camel_case_types)]
pub static $v_point_name: $crate::core::SyncPoint<
$crate::beh::pl::Mutex<$t>
> = $crate::core::SyncPoint::new($crate::beh::pl::const_mutex(
$t_make
));
};
{
#new_lock($lock:ident): $v_point_name:ident
} => {
#[allow(unused_mut)]
let mut $lock = $v_point_name.new_lock();
};
{
#drop_lock($lock: ident): $v_point_name:ident
} => {
$crate::core::SyncPoint::unlock(&$v_point_name, $lock);
};
}