# DispatcherTask

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/threading/struct-dispatchertask/

**struct** · [`ferroui-base`](/docs/0.5.0/api/ferroui-base/) · v0.5.0

```rust
struct DispatcherTask<T = ()>
```

The outcome of a future running on a [`Dispatcher`](/docs/0.5.0/api/ferroui-base/threading/struct-dispatcher/); what the reference
implementation returns as a task object.

The handle can be cloned and sent to other threads. It is a `Future`
that resolves to `Ok(result)` when the future has completed and to
`Err(Canceled)` when it was dropped before completing (the
dispatcher shut down, or the operation that was going to start it was
aborted). A panic raised by the future is re-raised to whoever observes
the outcome.

Deprecated: the dispatcher gives a `JoinHandle`
(`Dispatcher::spawn_local`, `spawn`,
`start_local` and their `_with_priority`
forms), a future of `Result<T, JoinError>` with one owner: a panic of the
future is `JoinError::Panicked`, a value, where this handle raises it
again; `JoinHandle::shared` gives several observers. `From` converts a
[`DispatcherTask`](/docs/0.5.0/api/ferroui-base/threading/struct-dispatchertask/) into a `JoinHandle` and back.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/threading/dispatcher_task.rs#L204)

> **Deprecated since 0.5.0.** use the `JoinHandle` of `Dispatcher::spawn_local`, `spawn` or `start_local` (a panic of the future is `JoinError::Panicked`, a value); `From` converts

## Members

- [`dispatcher`](#function-dispatcher)
- [`is_completed`](#function-is_completed)
- [`is_completed_successfully`](#function-is_completed_successfully)
- [`is_faulted`](#function-is_faulted)
- [`is_canceled`](#function-is_canceled)
- [`wait`](#function-wait)
- [`result`](#function-result)

<a id="function-dispatcher"></a>

### dispatcher

```rust
fn dispatcher(self: &Self) -> &Arc<Dispatcher>
```

The dispatcher the future runs on.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/threading/dispatcher_task.rs#L223)

<a id="function-is_completed"></a>

### is_completed

```rust
fn is_completed(self: &Self) -> bool
```

Whether the task has finished: completed, failed or canceled.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/threading/dispatcher_task.rs#L228)

<a id="function-is_completed_successfully"></a>

### is_completed_successfully

```rust
fn is_completed_successfully(self: &Self) -> bool
```

Whether the task ran to the end without panicking.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/threading/dispatcher_task.rs#L233)

<a id="function-is_faulted"></a>

### is_faulted

```rust
fn is_faulted(self: &Self) -> bool
```

Whether the future panicked.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/threading/dispatcher_task.rs#L238)

<a id="function-is_canceled"></a>

### is_canceled

```rust
fn is_canceled(self: &Self) -> bool
```

Whether the future was dropped before it completed.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/threading/dispatcher_task.rs#L243)

<a id="function-wait"></a>

### wait

```rust
fn wait(self: &Self) -> Result<(), Canceled>
```

Blocks until the task has finished. Only supported on threads other
than the dispatcher thread, unless the task has already finished.
## Panics
Re-raises the panic of the future. Panics when the task is still
running and the calling thread is the dispatcher thread.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/threading/dispatcher_task.rs#L267)

<a id="function-result"></a>

### result

```rust
fn result(self: &Self) -> Result<T, Canceled>
```

Blocks like `wait` and takes the result.
## Panics
See `wait`. Also panics when the result has already been
taken, and when a result that is not `Send` is requested from another
thread.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/threading/dispatcher_task.rs#L290)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `IntoFuture`
- `ToOwned`
- `ErasedDestructor`
- `IntoEither`
- `Clone`
- `Debug`
- `Future`
- `From<JoinHandle<T>>`
- `From<DispatcherTask<T>>`

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
