Skip to main content

Closure

Struct Closure 

Source
pub struct Closure<F, R> { /* private fields */ }
Expand description

A simple closure-based task implementation.

Implementations§

Source§

impl<F, R> Closure<F, R>
where F: FnOnce() -> R + Send + 'static, R: Send + 'static,

Source

pub fn new(func: F, context: TaskContext) -> Closure<F, R>

Create a new closure task.

Source

pub fn then<G, S>(self, continuation: G) -> Chained<Closure<F, R>, G>
where G: FnOnce(R) -> S + Send + 'static, S: Send + 'static,

Chain another operation after this task.

Source

pub fn map<G, S>(self, mapper: G) -> Mapped<Closure<F, R>, G>
where G: FnOnce(R) -> S + Send + 'static, S: Send + 'static,

Map the output of this task.

Trait Implementations§

Source§

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

Source§

type Output = R

The output type produced by this task.
Source§

fn execute(self) -> <Closure<F, R> as Task>::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, R> Freeze for Closure<F, R>
where BaseTask<F, R>: Freeze,

§

impl<F, R> RefUnwindSafe for Closure<F, R>
where BaseTask<F, R>: RefUnwindSafe,

§

impl<F, R> Send for Closure<F, R>
where BaseTask<F, R>: Send,

§

impl<F, R> Sync for Closure<F, R>
where BaseTask<F, R>: Sync,

§

impl<F, R> Unpin for Closure<F, R>
where BaseTask<F, R>: Unpin,

§

impl<F, R> UnsafeUnpin for Closure<F, R>
where BaseTask<F, R>: UnsafeUnpin,

§

impl<F, R> UnwindSafe for Closure<F, R>
where BaseTask<F, R>: 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.