Struct tokio_sync::semaphore::Permit [−][src]
pub struct Permit { /* fields omitted */ }Expand description
A semaphore permit
Tracks the lifecycle of a semaphore permit.
An instance of Permit is intended to be used with a single instance of
Semaphore. Using a single instance of Permit with multiple semaphore
instances will result in unexpected behavior.
Permit does not release the permit back to the semaphore on drop. It
is the user’s responsibility to ensure that Permit::release is called
before dropping the permit.
Implementations
Create a new Permit.
The permit begins in the “unacquired” state.
Examples
use tokio_sync::semaphore::Permit; let permit = Permit::new(); assert!(!permit.is_acquired());
Returns true if the permit has been acquired
Try to acquire the permit. If no permits are available, the current task is notified once a new permit becomes available.
Try to acquire the permit.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Permitimpl !UnwindSafe for Permit