pub struct TaskManager { /* private fields */ }Expand description
Hands out connection IDs, and routes each registered ID to its mailbox.
Implementations§
Source§impl TaskManager
impl TaskManager
pub fn new() -> Self
Sourcepub async fn wait_for_task(&mut self) -> Option<ManagerTask>
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.
pub fn get_task_sender(&self) -> TaskSender
pub fn get_conn_sender_chan( &self, conn_id: &RemoteConnId, ) -> Option<SenderChan<ConnTask>>
pub fn has_conn_sender(&self, conn_id: &RemoteConnId) -> bool
pub fn active_conn_count(&self) -> usize
Sourcepub fn idle_conn_count(&self) -> usize
pub fn idle_conn_count(&self) -> usize
IDs returned and not yet handed out again, resting ones included.
Sourcepub fn drop_conn_sender(&mut self, conn_id: RemoteConnId) -> bool
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.
Sourcepub fn recycle_conn_id(&mut self, conn_id: RemoteConnId)
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.
Sourcepub fn get_conn_id(
&mut self,
registered: impl Iterator<Item = RemoteConnId> + Clone,
) -> Option<RemoteConnId>
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.
pub fn sign_up_conn_sender( &mut self, conn_id: RemoteConnId, sender: SenderChan<ConnTask>, )
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for TaskManager
impl !UnwindSafe for TaskManager
impl Forget for TaskManager
impl Freeze for TaskManager
impl Move for TaskManager
impl Send for TaskManager
impl Sync for TaskManager
impl Unpin for TaskManager
impl UnsafeUnpin for TaskManager
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> 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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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