pub struct PlaceholderGuard<'a, Key, Val, We, B, L> {
lifecycle: &'a L,
shard: &'a RwLock<CacheShard<Key, Val, We, B, L, Arc<Placeholder<Val>>>>,
shared: Arc<Placeholder<Val>>,
inserted: bool,
}Fields§
§lifecycle: &'a L§shard: &'a RwLock<CacheShard<Key, Val, We, B, L, Arc<Placeholder<Val>>>>§inserted: boolImplementations§
Source§impl<'a, Key, Val, We, B, L> PlaceholderGuard<'a, Key, Val, We, B, L>
impl<'a, Key, Val, We, B, L> PlaceholderGuard<'a, Key, Val, We, B, L>
pub fn start_loading( lifecycle: &'a L, shard: &'a RwLock<CacheShard<Key, Val, We, B, L, Arc<Placeholder<Val>>>>, shared: Arc<Placeholder<Val>>, ) -> Self
fn handle_notification( lifecycle: &'a L, shard: &'a RwLock<CacheShard<Key, Val, We, B, L, Arc<Placeholder<Val>>>>, shared: Arc<Placeholder<Val>>, ) -> Result<Arc<Placeholder<Val>>, PlaceholderGuard<'a, Key, Val, We, B, L>>
fn join_waiters( _locked_shard: RwLockWriteGuard<'a, CacheShard<Key, Val, We, B, L, Arc<Placeholder<Val>>>>, shared: &Arc<Placeholder<Val>>, waiter_new: impl FnOnce() -> Option<Waiter>, ) -> bool
Source§impl<'a, Key: Eq + Hash, Val: Clone, We: Weighter<Key, Val>, B: BuildHasher, L: Lifecycle<Key, Val>> PlaceholderGuard<'a, Key, Val, We, B, L>
impl<'a, Key: Eq + Hash, Val: Clone, We: Weighter<Key, Val>, B: BuildHasher, L: Lifecycle<Key, Val>> PlaceholderGuard<'a, Key, Val, We, B, L>
pub fn join<Q>( lifecycle: &'a L, shard: &'a RwLock<CacheShard<Key, Val, We, B, L, Arc<Placeholder<Val>>>>, hash: u64, key: &Q, timeout: Option<Duration>, ) -> GuardResult<'a, Key, Val, We, B, L>
Sourcepub(crate) fn wait_for_placeholder(
lifecycle: &'a L,
shard: &'a RwLock<CacheShard<Key, Val, We, B, L, Arc<Placeholder<Val>>>>,
shard_guard: RwLockWriteGuard<'a, CacheShard<Key, Val, We, B, L, Arc<Placeholder<Val>>>>,
shared: Arc<Placeholder<Val>>,
deadline: Option<&mut Result<Duration, Instant>>,
) -> JoinResult<'a, Key, Val, We, B, L>
pub(crate) fn wait_for_placeholder( lifecycle: &'a L, shard: &'a RwLock<CacheShard<Key, Val, We, B, L, Arc<Placeholder<Val>>>>, shard_guard: RwLockWriteGuard<'a, CacheShard<Key, Val, We, B, L, Arc<Placeholder<Val>>>>, shared: Arc<Placeholder<Val>>, deadline: Option<&mut Result<Duration, Instant>>, ) -> JoinResult<'a, Key, Val, We, B, L>
Waits for an existing placeholder to be filled by another thread.
Registers the current thread as a waiter (consuming the shard guard to avoid races with placeholder removal), then parks until notified or timeout.
deadline is None for no timeout, or Some(&mut Ok(duration)) on the first
call. On first use the duration is converted in-place to Err(instant) so that
callers that retry (e.g. entry) preserve the original deadline across calls.
fn join_timeout( lifecycle: &'a L, shard: &'a RwLock<CacheShard<Key, Val, We, B, L, Arc<Placeholder<Val>>>>, shared: Arc<Placeholder<Val>>, parked_thread: Option<ThreadId>, notified: &AtomicBool, ) -> JoinResult<'a, Key, Val, We, B, L>
Source§impl<Key: Eq + Hash, Val: Clone, We: Weighter<Key, Val>, B: BuildHasher, L: Lifecycle<Key, Val>> PlaceholderGuard<'_, Key, Val, We, B, L>
impl<Key: Eq + Hash, Val: Clone, We: Weighter<Key, Val>, B: BuildHasher, L: Lifecycle<Key, Val>> PlaceholderGuard<'_, Key, Val, We, B, L>
Sourcepub fn insert(self, value: Val) -> Result<(), Val>
pub fn insert(self, value: Val) -> Result<(), Val>
Inserts the value into the placeholder
Returns Err if the placeholder isn’t in the cache anymore.
A placeholder can be removed as a result of a remove call
or a non-placeholder insert with the same key.
Sourcepub fn insert_with_lifecycle(self, value: Val) -> Result<L::RequestState, Val>
pub fn insert_with_lifecycle(self, value: Val) -> Result<L::RequestState, Val>
Inserts the value into the placeholder
Returns Err if the placeholder isn’t in the cache anymore.
A placeholder can be removed as a result of a remove call
or a non-placeholder insert with the same key.