pub struct ResettableOnceLock<T> { /* private fields */ }Expand description
ResettableOnceLock provides thread-safe access to a value of type T via a specific state
machine.
- Fresh values of the lock start in a “to be updated” state.
- When values are in “to be updated” then calls to getwill return None.
- In the to be updated state, the first call to get_or_updatewill runupdateon the object stored in the lock and transition the lock to the “updated” state.
- Once in the updated state, calls to getwill return a reference to the shared object, future calls toget_or_updatewill behave just like a call togetin this way.
- A call to resetwill transition the lock back to the “to be updated” state. Crucially, this requires mutable access to the lock object, making the patterns expressable via this lock less expressive than a regular mutex.
Implementations§
Source§impl<T> ResettableOnceLock<T>
 
impl<T> ResettableOnceLock<T>
Trait Implementations§
impl<T: Send> Send for ResettableOnceLock<T>
impl<T: Send> Sync for ResettableOnceLock<T>
Auto Trait Implementations§
impl<T> !Freeze for ResettableOnceLock<T>
impl<T> !RefUnwindSafe for ResettableOnceLock<T>
impl<T> Unpin for ResettableOnceLock<T>where
    T: Unpin,
impl<T> UnwindSafe for ResettableOnceLock<T>where
    T: UnwindSafe,
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