Struct TaskBuilder

Source
pub struct TaskBuilder { /* private fields */ }
Expand description

Builder to create a new task

Implementations§

Source§

impl TaskBuilder

Source

pub fn new(name: impl Into<Cow<'static, str>>) -> Self

Start the construction of a new task with the given name

Source

pub fn id(&self) -> usize

Unique id of the task we are creating

Source

pub fn set_run_token(self, run_token: RunToken) -> Self

Set the run_token for the task. It is sometimes nessesary to know the run_token of a task before it is created

Source

pub fn critical(self) -> Self

If the task fails the whole application should be stopped

Source

pub fn main(self) -> Self

If the task stops, the whole application should be stopped

Source

pub fn abort(self) -> Self

Cancel the task by dropping the future, instead of only setting the cancel token

Source

pub fn no_shutdown(self) -> Self

Keep the task running on shutdown

Source

pub fn shutdown_order(self, shutdown_order: i32) -> Self

Tasks with a lower shutdown order are stopped earlier on shutdown

Source

pub fn create<T: 'static + Send + Sync, E: Debug + Sync + Send + 'static, Fu: Future<Output = Result<T, E>> + Send + 'static, F: FnOnce(RunToken) -> Fu>( self, fun: F, ) -> Arc<Task<T, E>>

Create the new task

Auto Trait Implementations§

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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.