pub struct Permit { /* fields omitted */ }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.
Create a new Permit.
The permit begins in the "unacquired" state.
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.
Release a permit back to the semaphore
This function panics if called when the permit has not yet been
acquired.
Forget the permit without releasing it back to the semaphore.
After calling forget, poll_acquire is able to acquire new permit
from the sempahore.
Repeatedly calling forget without associated calls to add_permit
will result in the semaphore losing all permits.
This function panics if called when the permit has not yet been
acquired.
Formats the value using the given formatter. Read more
🔬 This is a nightly-only experimental API. (try_from)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from)
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from)
🔬 This is a nightly-only experimental API. (get_type_id)
this method will likely be replaced by an associated static