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: u32Implementations§
Source§impl Task
impl Task
Sourcepub fn new_for_cpu<F, Output>(
priority: Priority,
estimated_cost: u32,
work_fn: F,
result_tx: Sender<Result<Output, TaskError>>,
) -> Self
pub fn new_for_cpu<F, Output>( priority: Priority, estimated_cost: u32, work_fn: F, result_tx: Sender<Result<Output, TaskError>>, ) -> Self
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.
Sourcepub fn run(self) -> TaskExecutionOutcome
pub fn run(self) -> TaskExecutionOutcome
Executes the wrapped user function.
This is called by the VibeNode worker thread.
Trait Implementations§
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> 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