Struct rsevents_extra::SemaphoreGuard
source · pub struct SemaphoreGuard<'a> { /* private fields */ }
Expand description
The concurrency token returned by Semaphore::wait()
, allowing access to the
concurrency-limited region/code. Gives up its slot when dropped, allowing another thread to
enter the semaphore in its place.
SemaphoreGuard
instances should never be passed to std::mem::forget()
–
SemaphoreGuard::forget()
should be called instead to forget a SemaphoreGuard
and
permanently decrease the available concurrency.
Implementations§
source§impl SemaphoreGuard<'_>
impl SemaphoreGuard<'_>
sourcepub fn forget(self)
pub fn forget(self)
Safely “forgets” a semaphore’s guard, permanently reducing the concurrency limit of the
associated Semaphore
. SemaphoreGuard::forget()
internally decrements the semaphore’s
availablibility counter to make sure that future calls to Semaphore::release()
or
Semaphore::try_release()
do not incorrectly report failure.
A SemaphoreGuard
instance should never be passed to std::mem::forget()
directly, as that
would violate the internal contract; this method should be used instead.