#[cfg(feature = "persistence")]
pub(super) struct GenerationGate(parking_lot::RwLock<()>);
#[cfg(feature = "persistence")]
impl GenerationGate {
pub(super) fn new() -> Self {
Self(parking_lot::RwLock::new(()))
}
pub(super) fn read(&self) -> GenerationReadGuard<'_> {
self.0.read()
}
pub(super) fn write(&self) -> parking_lot::RwLockWriteGuard<'_, ()> {
self.0.write()
}
}
#[cfg(not(feature = "persistence"))]
pub(super) struct GenerationGate;
#[cfg(not(feature = "persistence"))]
impl GenerationGate {
pub(super) fn new() -> Self {
Self
}
pub(super) fn read(&self) -> GenerationReadGuard<'_> {
let Self = *self;
std::marker::PhantomData
}
}
#[cfg(feature = "persistence")]
pub(super) type GenerationReadGuard<'a> = parking_lot::RwLockReadGuard<'a, ()>;
#[cfg(not(feature = "persistence"))]
pub(super) type GenerationReadGuard<'a> = std::marker::PhantomData<&'a ()>;
pub(super) struct GenerationGuard<'a> {
pub(super) _guard: GenerationReadGuard<'a>,
}