Skip to main content

Spawner

Struct Spawner 

Source
pub struct Spawner<F> { /* private fields */ }
Expand description

A task that can spawn other tasks during its execution.

This provides dynamic task creation capabilities, allowing tasks to generate additional work based on runtime conditions.

Implementations§

Source§

impl<F> Spawner<F>

Source

pub fn new(spawner: F, context: TaskContext) -> Self

Create a new spawner task.

Trait Implementations§

Source§

impl<F> Task for Spawner<F>
where F: FnOnce() + Send + 'static,

Source§

type Output = ()

The output type produced by this task.
Source§

fn execute(self) -> Self::Output

Execute this task to completion.
Source§

fn context(&self) -> &TaskContext

Get the task context for scheduling and debugging.
Source§

fn is_stealable(&self) -> bool

Check if this task can be stolen by another thread.
Source§

fn estimated_cost(&self) -> u32

Estimate the computational cost of this task (for load balancing).

Auto Trait Implementations§

§

impl<F> Freeze for Spawner<F>
where Option<F>: Freeze,

§

impl<F> RefUnwindSafe for Spawner<F>

§

impl<F> Send for Spawner<F>
where Option<F>: Send,

§

impl<F> Sync for Spawner<F>
where Option<F>: Sync,

§

impl<F> Unpin for Spawner<F>
where Option<F>: Unpin,

§

impl<F> UnsafeUnpin for Spawner<F>
where Option<F>: UnsafeUnpin,

§

impl<F> UnwindSafe for Spawner<F>
where Option<F>: UnwindSafe,

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, 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> TaskExt for T
where T: Task,

Source§

fn map<F, R>(self, mapper: F) -> Mapped<Self, F>
where F: FnOnce(Self::Output) -> R,

Transform the output of this task.
Source§

fn with_context(self, context: TaskContext) -> ContextualTask<Self>

Convert this task into a task with the given context.
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.