pub struct RoleMaskCache { /* private fields */ }Expand description
Role → resolved mask, valid for exactly one commit sequence.
Resolving a role is a full scan of the label vector, and with a
visible_where predicate it is also
a property read per candidate node. A scoped reader pays that on every
request, and between two writes the answer cannot have changed — so it is
paid once and remembered.
Never stale: an entry records the store’s commit_seq at the moment it
was built and is served only when that is still the current one. Any write
bumps commit_seq and the entry simply stops matching. The cache can be
cold, but it cannot be wrong.
commit_seq does not move when a role definition changes — roles.json
is a sidecar, not a WAL record — so the owner of the cache installs a fresh
one whenever roles are rewritten or the store is reloaded. That also leaves
any reader snapshot holding the old Arc with a private cache, so a
snapshot frozen against the old definitions can never publish an answer the
live handle would read back.
Implementations§
Source§impl RoleMaskCache
impl RoleMaskCache
pub fn new() -> Self
Sourcepub fn get_or_build(
&self,
role: &str,
version: u64,
build: impl FnOnce() -> Result<NodeMask>,
) -> Result<Arc<NodeMask>>
pub fn get_or_build( &self, role: &str, version: u64, build: impl FnOnce() -> Result<NodeMask>, ) -> Result<Arc<NodeMask>>
Return the memoised mask for role at version, building it if the
entry is absent or was built against a different commit sequence.
build runs outside the lock: it reads the store, and the cache must
never be a lock ordering between two readers.
Trait Implementations§
Source§impl Default for RoleMaskCache
impl Default for RoleMaskCache
Source§fn default() -> RoleMaskCache
fn default() -> RoleMaskCache
Auto Trait Implementations§
impl !Freeze for RoleMaskCache
impl RefUnwindSafe for RoleMaskCache
impl Send for RoleMaskCache
impl Sync for RoleMaskCache
impl Unpin for RoleMaskCache
impl UnsafeUnpin for RoleMaskCache
impl UnwindSafe for RoleMaskCache
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.