Skip to main content

TaskManager

Struct TaskManager 

Source
pub struct TaskManager { /* private fields */ }
Expand description

Hands out connection IDs, and routes each registered ID to its mailbox.

Implementations§

Source§

impl TaskManager

Source

pub fn new() -> Self

Source

pub async fn wait_for_task(&mut self) -> Option<ManagerTask>

The next task to route.

None would mean every sender is gone, which cannot happen while the manager holds one of its own.

Source

pub fn get_task_sender(&self) -> TaskSender

Source

pub fn get_conn_sender_chan( &self, conn_id: &RemoteConnId, ) -> Option<SenderChan<ConnTask>>

Source

pub fn has_conn_sender(&self, conn_id: &RemoteConnId) -> bool

Source

pub fn active_conn_count(&self) -> usize

Source

pub fn idle_conn_count(&self) -> usize

IDs returned and not yet handed out again, resting ones included.

Source

pub fn drop_conn_sender(&mut self, conn_id: RemoteConnId) -> bool

Stop routing to a connection, without returning its ID to the idle pool.

Dropping the sender and recycling the ID are separate steps because they become safe at different moments. The sender must go the instant the connection stops being usable — a retirement, a subscribe that found it unreachable — but the socket task is still running then, and still owns a guard that will deregister when it unwinds. Recycling at that point would let a freshly accepted socket take the ID and register under it, and the old task’s deregistration, which matches on ID alone, would unwind the replacement instead.

So the ID stays out of circulation until Self::recycle_conn_id or rest_conn_id, which the manager calls when the guard’s deregistration finally arrives — the one point at which nothing will speak for that ID again. Every accepted connection produces exactly one such task, however it ends, so no ID is stranded.

Source

pub fn recycle_conn_id(&mut self, conn_id: RemoteConnId)

Return an ID to the idle pool, if it is not already there: an ID queued twice could go to two connections before either had signed up.

Source

pub fn get_conn_id( &mut self, registered: impl Iterator<Item = RemoteConnId> + Clone, ) -> Option<RemoteConnId>

An ID for a newly accepted connection: an idle one when one is free, otherwise one never handed out. registered names the IDs the service map still holds, which are never reused. An ended registration’s ID is idle only once it has rested ten seconds, so that the registration replacing it does not take it.

None once every ID is held, which takes four billion connections open at once: the caller refuses the connection, and an ID that comes back is handed out again.

Source

pub fn sign_up_conn_sender( &mut self, conn_id: RemoteConnId, sender: SenderChan<ConnTask>, )

Trait Implementations§

Source§

impl Default for TaskManager

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more