#[cfg(feature = "send")] mod inner { use parking_lot::{RawMutex, RawThreadId}; use std::sync::{Arc, Weak}; pub(crate) type XRc = Arc; pub(crate) type XWeak = Weak; pub(crate) type ReentrantMutex = parking_lot::ReentrantMutex; pub(crate) type ReentrantMutexGuard<'a, T> = parking_lot::ReentrantMutexGuard<'a, T>; pub(crate) type ArcReentrantMutexGuard = parking_lot::lock_api::ArcReentrantMutexGuard; } #[cfg(not(feature = "send"))] mod inner { use std::ops::Deref; use std::rc::{Rc, Weak}; pub(crate) type XRc = Rc; pub(crate) type XWeak = Weak; pub(crate) struct ReentrantMutex(T); impl ReentrantMutex { #[inline(always)] pub(crate) fn new(val: T) -> Self { ReentrantMutex(val) } #[inline(always)] pub(crate) fn lock(&self) -> ReentrantMutexGuard<'_, T> { ReentrantMutexGuard(&self.0) } #[inline(always)] pub(crate) fn lock_arc(self: &XRc) -> ArcReentrantMutexGuard { ArcReentrantMutexGuard(Rc::clone(self)) } #[inline(always)] pub(crate) fn into_lock_arc(self: XRc) -> ArcReentrantMutexGuard { ArcReentrantMutexGuard(self) } #[inline(always)] pub(crate) fn data_ptr(&self) -> *const T { &self.0 as *const _ } } pub(crate) struct ReentrantMutexGuard<'a, T>(&'a T); impl Deref for ReentrantMutexGuard<'_, T> { type Target = T; #[inline(always)] fn deref(&self) -> &Self::Target { self.0 } } pub(crate) struct ArcReentrantMutexGuard(XRc>); impl Deref for ArcReentrantMutexGuard { type Target = T; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0.0 } } } pub(crate) use inner::{ArcReentrantMutexGuard, ReentrantMutex, ReentrantMutexGuard, XRc, XWeak};