Struct state_store::SSCached
source · pub struct SSCached<S: Any>(/* private fields */);
Expand description
A thread-safe cached reference to a system-wide state.
Internally, this contains a Weak pointer to S
,
which is upgraded / updated whenenver the caller invokes get()
.
Implementations§
source§impl<S: Any> SSCached<S>
impl<S: Any> SSCached<S>
sourcepub fn get(&self) -> Option<Arc<S>>
pub fn get(&self) -> Option<Arc<S>>
Tries to upgrade the internal Weak pointer to a Strong (Arc) pointer.
If successful, the weak pointer is still valid, so we return the Arc<S>
.
If not, the current internal Weak reference is None, so we try to reaquire it.
If it cannot be reacquired, there is currently not a system-wide state of type S
,
so we return None.
Auto Trait Implementations§
impl<S> RefUnwindSafe for SSCached<S>
impl<S> Send for SSCached<S>
impl<S> Sync for SSCached<S>
impl<S> Unpin for SSCached<S>
impl<S> UnwindSafe for SSCached<S>where S: RefUnwindSafe,
Blanket Implementations§
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
Mutably borrows from an owned value. Read more