pub struct RundownRef { /* private fields */ }
Expand description
Tracks the status of run-down protection for an object. The type would be embedded in the object needing run-down protection.
Implementations§
Source§impl RundownRef
impl RundownRef
Sourcepub fn new() -> Self
pub fn new() -> Self
Initializes a new RundownRef
.
Sourcepub fn re_init(&self)
pub fn re_init(&self)
Re-initialize this instance so it can be used again. It is only valid to call re_init once the object is completely run-down, via the wait_for_rundown method.
§Important
The moment this method returns, new rundown protection requests can succeed. You must perform all re-initialization of the shared object the run-down protection is guarding before you call this method.
Sourcepub fn try_acquire(&self) -> Result<RundownGuard<'_>, RundownError>
pub fn try_acquire(&self) -> Result<RundownGuard<'_>, RundownError>
Attempts to acquire rundown protection on this RundownRef
,
returns the RundownGuard
which holds the reference count,
or returns an error if the object is already being rundown.
Sourcepub fn wait_for_rundown(&self)
pub fn wait_for_rundown(&self)
Blocks thread execution until there are no outstanding reference
counts taken on the RundownRef
, and the internal representation
has been marked with [RundownFlags::RUNDOWN_IN_PROGRESS
] to signal
that no other thread can safely acquire a reference count afterwards.
§Important
-
This method is not thread safe, it must only be called by one thread.
-
This method is however idempotent, it can be called multiple times.