pub struct PollSemaphore { /* private fields */ }
Expand description
A wrapper around Semaphore
that provides a poll_acquire
method.
Implementations§
Source§impl PollSemaphore
impl PollSemaphore
Sourcepub fn clone_inner(&self) -> Arc<Semaphore>
pub fn clone_inner(&self) -> Arc<Semaphore>
Obtain a clone of the inner semaphore.
Sourcepub fn into_inner(self) -> Arc<Semaphore>
pub fn into_inner(self) -> Arc<Semaphore>
Get back the inner semaphore.
Sourcepub fn poll_acquire(
&mut self,
cx: &mut Context<'_>,
) -> Poll<Option<OwnedSemaphorePermit>>
pub fn poll_acquire( &mut self, cx: &mut Context<'_>, ) -> Poll<Option<OwnedSemaphorePermit>>
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.
Sourcepub fn poll_acquire_many(
&mut self,
cx: &mut Context<'_>,
permits: u32,
) -> Poll<Option<OwnedSemaphorePermit>>
pub fn poll_acquire_many( &mut self, cx: &mut Context<'_>, permits: u32, ) -> Poll<Option<OwnedSemaphorePermit>>
Poll to acquire many permits 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 the permits become 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.
Sourcepub fn available_permits(&self) -> usize
pub fn available_permits(&self) -> usize
Returns the current number of available permits.
This is equivalent to the Semaphore::available_permits
method on the
tokio::sync::Semaphore
type.
Sourcepub fn add_permits(&self, n: usize)
pub fn add_permits(&self, n: usize)
Adds n
new permits to the semaphore.
The maximum number of permits is Semaphore::MAX_PERMITS
, 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§
Source§impl AsRef<Semaphore> for PollSemaphore
impl AsRef<Semaphore> for PollSemaphore
Source§impl Clone for PollSemaphore
impl Clone for PollSemaphore
Source§fn clone(&self) -> PollSemaphore
fn clone(&self) -> PollSemaphore
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for PollSemaphore
impl Debug for PollSemaphore
Source§impl Stream for PollSemaphore
impl Stream for PollSemaphore
Source§type Item = OwnedSemaphorePermit
type Item = OwnedSemaphorePermit
Auto Trait Implementations§
impl Freeze for PollSemaphore
impl !RefUnwindSafe for PollSemaphore
impl Send for PollSemaphore
impl Sync for PollSemaphore
impl Unpin for PollSemaphore
impl !UnwindSafe for PollSemaphore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 32 bytes