imago/sync_primitives/
mod.rs1#[cfg(feature = "async")]
6mod async_impl;
7#[cfg(feature = "sync")]
8mod sync_impl;
9
10#[cfg(feature = "async")]
11#[allow(unused_imports)]
12pub(crate) use tokio::sync::{
13 Mutex, MutexGuard, OwnedRwLockReadGuard, OwnedRwLockWriteGuard, RwLock, RwLockReadGuard,
14 RwLockWriteGuard,
15};
16
17#[cfg(feature = "async")]
18#[allow(unused_imports)]
19pub(crate) use async_impl::OwnedRwLock;
20
21#[cfg(feature = "sync")]
22#[allow(unused_imports)]
23pub(crate) use parking_lot::{Mutex, MutexGuard, RwLock, RwLockReadGuard, RwLockWriteGuard};
24
25#[cfg(feature = "sync")]
26#[allow(unused_imports)]
27pub(crate) use sync_impl::{OwnedRwLock, OwnedRwLockReadGuard, OwnedRwLockWriteGuard};
28
29#[derive(Debug)]
33pub(crate) enum RwLockEitherGuard<'a, T> {
34 Read(#[allow(dead_code)] OwnedRwLockReadGuard<T>),
36
37 Write(#[allow(dead_code)] &'a OwnedRwLockWriteGuard<T>),
39}
40
41impl<T> From<OwnedRwLockReadGuard<T>> for RwLockEitherGuard<'_, T> {
42 fn from(guard: OwnedRwLockReadGuard<T>) -> Self {
43 RwLockEitherGuard::Read(guard)
44 }
45}
46
47impl<'a, T> From<&'a OwnedRwLockWriteGuard<T>> for RwLockEitherGuard<'a, T> {
48 fn from(guard: &'a OwnedRwLockWriteGuard<T>) -> Self {
49 RwLockEitherGuard::Write(guard)
50 }
51}