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
impl 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.Future<Output = ()> + Send + 'static: The future to spawn on the task pool.
§Returns
bool: true if the task was successfully sent, false otherwise.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Task
impl RefUnwindSafe for Task
impl Send for Task
impl Sync for Task
impl Unpin for Task
impl UnsafeUnpin for Task
impl UnwindSafe for Task
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
Mutably borrows from an owned value. Read more