# tokio_util::sync::PollSemaphore - Rust
API documentation for the Rust `PollSemaphore` struct in crate `tokio_util`.
Keywords: rust, rustlang, rust-lang, PollSemaphore

# Struct tokio_util::sync::PollSemaphore [−] [src]

    pub struct PollSemaphore { /* fields omitted */ }

A wrapper around `Semaphore` that provides a `poll_acquire` method.

## Implementations

### `impl PollSemaphore` [src]

#### `pub fn new(semaphore: Arc<Semaphore>) -> Self` [src]

Create a new `PollSemaphore`.

#### `pub fn close(&self)` [src]

Closes the semaphore.

#### `pub fn clone_inner(&self) -> Arc<Semaphore>` [src]

Obtain a clone of the inner semaphore.

#### `pub fn into_inner(self) -> Arc<Semaphore>` [src]

Get back the inner semaphore.

#### `pub fn poll_acquire(
&mut self,
cx: &mut Context<'_>
) -> Poll<Option<OwnedSemaphorePermit>>` [src]

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.

## Trait Implementations

### `impl Clone for PollSemaphore` [src]

#### `fn clone(&self) -> PollSemaphore` [src]

Returns a copy of the value. Read more

#### `pub fn clone_from(&mut self, source: &Self)`1.0.0 [src]

Performs copy-assignment from `source`. Read more

### `impl Debug for PollSemaphore` [src]

#### `fn fmt(&self, f: &mut Formatter<'_>) -> Result` [src]

Formats the value using the given formatter. Read more

### `impl Stream for PollSemaphore` [src]

#### `type Item = OwnedSemaphorePermit`

Values yielded by the stream.

#### `fn poll_next(
self: Pin<&mut Self>,
cx: &mut Context<'_>
) -> Poll<Option<OwnedSemaphorePermit>>` [src]

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

#### `pub fn size_hint(&self) -> (usize, Option<usize>)` [src]

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

## Auto Trait Implementations

### `impl !RefUnwindSafe for PollSemaphore` [src]

### `impl Send for PollSemaphore` [src]

### `impl Sync for PollSemaphore` [src]

### `impl Unpin for PollSemaphore` [src]

### `impl !UnwindSafe for PollSemaphore` [src]

## Blanket Implementations

### `impl<T> Any for T where
T: 'static + ?Sized,` [src]

#### `pub fn type_id(&self) -> TypeId` [src]

Gets the `TypeId` of `self`. Read more

### `impl<T> Borrow<T> for T where
T: ?Sized,` [src]

#### `pub fn borrow(&self) -> &T` [src]

Immutably borrows from an owned value. Read more

### `impl<T> BorrowMut<T> for T where
T: ?Sized,` [src]

#### `pub fn borrow_mut(&mut self) -> &mut T` [src]

Mutably borrows from an owned value. Read more

### `impl<T> From<T> for T` [src]

#### `pub fn from(t: T) -> T` [src]

Performs the conversion.

### `impl<T, U> Into<U> for T where
U: From<T>,` [src]

#### `pub fn into(self) -> U` [src]

Performs the conversion.

### `impl<T> ToOwned for T where
T: Clone,` [src]

#### `type Owned = T`

The resulting type after obtaining ownership.

#### `pub fn to_owned(&self) -> T` [src]

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

#### `pub fn clone_into(&self, target: &mut T)` [src]

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

recently added

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

### `impl<T, U> TryFrom<U> for T where
U: Into<T>,` [src]

#### `type Error = Infallible`

The type returned in the event of a conversion error.

#### `pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>` [src]

Performs the conversion.

### `impl<T, U> TryInto<U> for T where
U: TryFrom<T>,` [src]

#### `type Error = <U as TryFrom<T>>::Error`

The type returned in the event of a conversion error.

#### `pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>` [src]

Performs the conversion.