[][src]Module tokio_sync::semaphore

Thread-safe, asynchronous counting semaphore.

A Semaphore instance holds a set of permits. Permits are used to synchronize access to a shared resource.

Before accessing the shared resource, callers acquire a permit from the semaphore. Once the permit is acquired, the caller then enters the critical section. If no permits are available, then acquiring the semaphore returns NotReady. The task is notified once a permit becomes available.

Structs

AcquireError

Error returned by Permit::poll_acquire.

Permit

A semaphore permit

Semaphore

Futures-aware semaphore.

TryAcquireError

Error returned by Permit::try_acquire.