Struct tokio_util::sync::PollSemaphore [−][src]
pub struct PollSemaphore { /* fields omitted */ }
Expand description
A wrapper around Semaphore
that provides a poll_acquire
method.
Implementations
impl PollSemaphore
[src]
impl PollSemaphore
[src]pub fn clone_inner(&self) -> Arc<Semaphore>
[src]
pub fn clone_inner(&self) -> Arc<Semaphore>
[src]Obtain a clone of the inner semaphore.
pub fn into_inner(self) -> Arc<Semaphore>
[src]
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]
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.
pub fn available_permits(&self) -> usize
[src]
pub fn available_permits(&self) -> usize
[src]Returns the current number of available permits.
This is equivalent to the Semaphore::available_permits
method on the
tokio::sync::Semaphore
type.
pub fn add_permits(&self, n: usize)
[src]
pub fn add_permits(&self, n: usize)
[src]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
impl AsRef<Semaphore> for PollSemaphore
[src]
impl AsRef<Semaphore> for PollSemaphore
[src]impl Clone for PollSemaphore
[src]
impl Clone for PollSemaphore
[src]fn clone(&self) -> PollSemaphore
[src]
fn clone(&self) -> PollSemaphore
[src]Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]Performs copy-assignment from source
. Read more
impl Debug for PollSemaphore
[src]
impl Debug for PollSemaphore
[src]impl Stream for PollSemaphore
[src]
impl Stream for PollSemaphore
[src]type Item = OwnedSemaphorePermit
type Item = OwnedSemaphorePermit
Values yielded by the stream.
Auto Trait Implementations
impl !RefUnwindSafe for PollSemaphore
impl Send for PollSemaphore
impl Sync for PollSemaphore
impl Unpin for PollSemaphore
impl !UnwindSafe for PollSemaphore
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
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]
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