pub struct PollSemaphore { /* private fields */ }
Expand description

A wrapper around Semaphore that provides a poll_acquire method.

Implementations

Create a new PollSemaphore.

Closes the semaphore.

Obtain a clone of the inner semaphore.

Get back the inner semaphore.

Poll to acquire a permit from the semaphore.

This can return the following values:

  • Poll::Pending if a permit is not currently available.
  • Poll::Ready(Some(permit)) if a permit was acquired.
  • Poll::Ready(None) if the semaphore has been closed.

When this method returns Poll::Pending, the current task is scheduled to receive a wakeup when a permit becomes available, or when the semaphore is closed. Note that on multiple calls to poll_acquire, only the Waker from the Context passed to the most recent call is scheduled to receive a wakeup.

Returns the current number of available permits.

This is equivalent to the Semaphore::available_permits method on the tokio::sync::Semaphore type.

Adds n new permits to the semaphore.

The maximum number of permits is usize::MAX >> 3, and this function will panic if the limit is exceeded.

This is equivalent to the Semaphore::add_permits method on the tokio::sync::Semaphore type.

Trait Implementations

Converts this type into a shared reference of the (usually inferred) input type.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Values yielded by the stream.

Attempt to pull out the next value of this stream, registering the current task for wakeup if the value is not yet available, and returning None if the stream is exhausted. Read more

Returns the bounds on the remaining length of the stream. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.