azul_core::task

Struct Task

Source
pub struct Task {
    pub after_completion_timer: Option<Timer>,
    /* private fields */
}
Expand description

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§

Source§

impl Task

Source

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

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

Source

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

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.

Source

pub fn is_finished(&self) -> bool

Returns true if the task has been finished, false otherwise

Trait Implementations§

Source§

impl Drop for Task

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Task

§

impl !RefUnwindSafe for Task

§

impl Send for Task

§

impl Sync for Task

§

impl Unpin for Task

§

impl !UnwindSafe 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 = 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.