[][src]Struct azul_core::task::Task

pub struct Task {
    pub after_completion_timer: Option<Timer>,
    // some fields omitted
}

A Task is a seperate thread that is owned by the framework.

In difference to a Thread, you don't have to await() the result of a Task, you can just hand the task to the framework (via AppResources::add_task) and the framework will automatically update the UI when the task is finished. This is useful to offload actions such as loading long files, etc. to a background thread.

Azul will join the thread automatically after it is finished (joining won't block the UI).

Fields

after_completion_timer: Option<Timer>

Timer that will run directly after this task is completed.

Implementations

impl Task[src]

pub fn new<U: Send + 'static>(
    data: Arc<Mutex<U>>,
    callback: TaskCallback<U>
) -> Self
[src]

Creates a new task from a callback and a set of input data - which has to be wrapped in an Arc<Mutex<T>>>.

pub fn then(self, timer: Timer) -> Self[src]

Stores a Timer that will run after the task has finished.

Often necessary to "clean up" or copy data from the background task into the UI.

pub fn is_finished(&self) -> bool[src]

Returns true if the task has been finished, false otherwise

Trait Implementations

impl Drop for Task[src]

Auto Trait Implementations

impl !RefUnwindSafe for Task

impl Send for Task

impl Sync for Task

impl Unpin for Task

impl !UnwindSafe for Task

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.