[][src]Struct async_listen::backpressure::Sender

pub struct Sender { /* fields omitted */ }

The handle that controls backpressure

It can be used to create tokens, changing limit and getting metrics.

See new for more details

Methods

impl Sender[src]

pub fn token(&self) -> Token[src]

Acquire a backpressure token

The token holds one unit of resource

Note: You can always acquire a token, even if capacity limit reached.

pub fn set_limit(&self, new_limit: usize)[src]

Change the limit for the number of connections

If limit is increased it's applied immediately. If limit is lowered, we can't drop connections. So listening stream is paused until there are less then new limit tokens alive (i.e. first dropped tokens may not unblock the stream).

pub fn get_active_tokens(&self) -> usize[src]

Returns the number of currently active tokens

Can return a value larger than limit if tokens are created manually.

This can be used for metrics or debugging. You should not rely on this value being in sync. There is also no way to wake-up when this value is lower than limit, also see has_capacity.

Trait Implementations

impl Clone for Sender[src]

impl Debug for Sender[src]

Auto Trait Implementations

impl RefUnwindSafe for Sender

impl Send for Sender

impl Sync for Sender

impl Unpin for Sender

impl UnwindSafe for Sender

Blanket Implementations

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

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

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

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

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

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

type Owned = T

The resulting type after obtaining ownership.

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.

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.