pub struct StoreLock<T: ?Sized>(/* private fields */);Expand description
Implementations§
Source§impl<T: ?Sized> StoreLock<T>
impl<T: ?Sized> StoreLock<T>
Sourcepub fn listener(&self) -> StoreLockListener<T>
pub fn listener(&self) -> StoreLockListener<T>
Returns a Listener which delivers messages to this.
Sourcepub fn lock(&self) -> impl DerefMut<Target = T> + use<'_, T>
pub fn lock(&self) -> impl DerefMut<Target = T> + use<'_, T>
Locks and returns access to the state.
Callers should be careful to hold the lock for a very short time (e.g. only to copy or take the data) or to do so only while messages will not be arriving. Otherwise, poor performance or deadlock may result.
§Panics
If it is called while the same thread has already acquired the lock, it may panic or hang, depending on the mutex implementation in use.
Sourcepub fn take(&self) -> T
pub fn take(&self) -> T
Replaces the current state with T::default() and returns it.
This is not more powerful than lock(),
but it offers the guarantee that it will hold the lock for as little time as possible.
It is equivalent to:
let replacement = T::default();
mem::replace(&mut *self.lock(), replacement)§Panics
If it is called while the same thread has already acquired the lock, it may panic or hang, depending on the mutex implementation in use.
Sourcepub fn receive<M>(&self, messages: &[M])where
T: Store<M>,
pub fn receive<M>(&self, messages: &[M])where
T: Store<M>,
Delivers messages like self.listener().receive(messages),
but without creating a temporary listener.
§Panics
If it is called while the same thread has already acquired the lock, it may panic or hang, depending on the mutex implementation in use.