Struct tokio_tasks::Task

source ·
pub struct Task<T: Send + Sync, E: Sync> { /* private fields */ }
Expand description

A possible running task, with a return value of Result<T, E>

Implementations§

source§

impl<T: Send + Sync, E: Send + Sync> Task<T, E>

source

pub async fn cancel(self: Arc<Self>)

Cancel the task, either by setting the cancel_token or by aborting it. Wait for it to finish Note that this function fill fail t

source

pub async fn wait(self: Arc<Self>) -> Result<T, WaitError<E>>

Wait for the task to finish.

Trait Implementations§

source§

impl<T: Send + Sync + 'static, E: Send + Sync + 'static> TaskBase for Task<T, E>

source§

fn shutdown_order(&self) -> i32

Return the shutdown order of this task as defined by the TaskBuilder
source§

fn name(&self) -> &str

Return the name of this task as defined by the TaskBuilder
source§

fn id(&self) -> usize

Return the unique id of this task
source§

fn cancel(self: Arc<Self>) -> BoxFuture<'static, ()>

Cantle the task, return futer that returns when the task is done
source§

fn main(&self) -> bool

If true the application will shut down with an error if this task returns
source§

fn abort(&self) -> bool

If this is true the task will be cancled by dropping the future instead of signaling the run token
source§

fn critical(&self) -> bool

If true the application will shut down with an error if this task returns with an error
source§

fn start_time(&self) -> f64

Unixtimestamp of when the task started
source§

fn run_token(&self) -> &RunToken

Get the run token associated with the task
source§

fn no_shutdown(&self) -> bool

Do not stop task on shutdown

Auto Trait Implementations§

§

impl<T, E> !RefUnwindSafe for Task<T, E>

§

impl<T, E> Send for Task<T, E>
where E: Send,

§

impl<T, E> Sync for Task<T, E>
where E: Send,

§

impl<T, E> Unpin for Task<T, E>

§

impl<T, E> !UnwindSafe for Task<T, E>

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

§

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

§

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.