Skip to main content

Task

Struct Task 

Source
pub struct Task {
    pub id: TaskId,
    pub priority: Priority,
    pub estimated_cost: u32,
    /* private fields */
}
Expand description

An internal representation of a unit of work.

This struct wraps the user’s closure in a type-erased Box<dyn FnOnce...>, allowing different kinds of functions to be stored and executed by workers.

Fields§

§id: TaskId§priority: Priority§estimated_cost: u32

Implementations§

Source§

impl Task

Source

pub fn new_for_cpu<F, Output>( priority: Priority, estimated_cost: u32, work_fn: F, result_tx: Sender<Result<Output, TaskError>>, ) -> Self
where F: FnOnce() -> Result<Output, TaskError> + Send + 'static, Output: Send + 'static,

Creates a new Task from a user-provided function.

This wraps the function in a new closure that handles panic catching and sending the result back over a channel.

Source

pub fn run(self) -> TaskExecutionOutcome

Executes the wrapped user function.

This is called by the VibeNode worker thread.

Trait Implementations§

Source§

impl Debug for Task

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Task

§

impl !Sync for Task

§

impl !UnwindSafe for Task

§

impl Freeze for Task

§

impl Send for Task

§

impl Unpin for Task

§

impl UnsafeUnpin for Task

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, 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.