pub struct Task { /* private fields */ }Expand description
Task manager for handling async tasks across worker threads.
This structure manages a pool of task senders distributed across multiple worker threads, enabling efficient round-robin task scheduling with event-driven wake-up mechanism.
Implementations§
Source§impl Task
Inherent implementation of Task.
impl Task
Inherent implementation of Task.
Sourcepub fn try_spawn_local<F>(&self, index_opt: Option<usize>, hook: F) -> bool
pub fn try_spawn_local<F>(&self, index_opt: Option<usize>, hook: F) -> bool
Attempts to spawn a server task onto the global server task pool.
This function sends the task to one of the worker threads in the pool. The worker is selected using a round-robin algorithm based on an atomic counter, or a forced index if provided.
§Arguments
Option<usize>- An optional index to force selection of a specific worker. If None, the worker is selected using round-robin distribution.F- The future to spawn on the task pool, which requires theFuture<Output = ()> + Send + 'staticbound.
§Returns
bool- true if the task was successfully sent, false otherwise.
Source§impl Task
Implements impl #impl_generics #name #ty_generics #where_clause.
impl Task
Implements impl #impl_generics #name #ty_generics #where_clause.
pub fn get_pool( &self, ) -> &Vec<UnboundedSender<Pin<Box<dyn Future<Output = ()> + Send>>>>
pub fn get_mut_pool( &mut self, ) -> &mut Vec<UnboundedSender<Pin<Box<dyn Future<Output = ()> + Send>>>>
pub fn set_pool( &mut self, val: Vec<UnboundedSender<Pin<Box<dyn Future<Output = ()> + Send>>>>, ) -> &mut Task
pub fn get_counter(&self) -> &Arc<Atomic<usize>> ⓘ
pub fn get_mut_counter(&mut self) -> &mut Arc<Atomic<usize>> ⓘ
pub fn set_counter(&mut self, val: Arc<Atomic<usize>>) -> &mut Task
pub fn get_shutdown(&self) -> &Arc<Atomic<bool>> ⓘ
pub fn get_mut_shutdown(&mut self) -> &mut Arc<Atomic<bool>> ⓘ
pub fn set_shutdown(&mut self, val: Arc<Atomic<bool>>) -> &mut Task
pub fn get_notifies(&self) -> &Vec<Arc<Notify>>
pub fn get_mut_notifies(&mut self) -> &mut Vec<Arc<Notify>>
pub fn set_notifies(&mut self, val: Vec<Arc<Notify>>) -> &mut Task
Trait Implementations§
Source§impl Debug for Task
Implements impl #impl_generics ::std::fmt::Debug for #name #ty_generics #where_clause.
impl Debug for Task
Implements impl #impl_generics ::std::fmt::Debug for #name #ty_generics #where_clause.
Source§impl Display for Task
Implements impl #impl_generics ::std::fmt::Display for #name #ty_generics #where_clause.
impl Display for Task
Implements impl #impl_generics ::std::fmt::Display for #name #ty_generics #where_clause.