# DispatcherTaskScheduler

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

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

```rust
struct DispatcherTaskScheduler
```

Runs futures on a [`Dispatcher`](/docs/0.5.0/api/ferroui-base/threading/struct-dispatcher/) at a fixed priority: every poll of a
future started here is a dispatcher job of that priority.

The futures are tasks of the dispatcher
(`Dispatcher::spawn_local_with_priority`,
`Dispatcher::spawn_with_priority`), with handles that keep the contract
of [`DispatcherTask`](/docs/0.5.0/api/ferroui-base/threading/struct-dispatchertask/).

Obtained from `Dispatcher::to_task_scheduler` and
`Dispatcher::to_task_scheduler_with_priority`.

Deprecated: the dispatcher spawns futures itself and gives a `JoinHandle`:
`spawn` is `Dispatcher::spawn_with_priority``(move ||
future, priority)`, `spawn_local` is
`Dispatcher::spawn_local_with_priority` and
`start_local` is
`Dispatcher::start_local_with_priority`.

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

> **Deprecated since 0.5.0.** use `Dispatcher::spawn_with_priority`, `spawn_local_with_priority` or `start_local_with_priority`, which give a `JoinHandle`

## Members

- [`dispatcher`](#function-dispatcher)
- [`priority`](#function-priority)
- [`spawn`](#function-spawn)
- [`spawn_local`](#function-spawn_local)
- [`start_local`](#function-start_local)

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

### dispatcher

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



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

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

### priority

```rust
fn priority(self: &Self) -> DispatcherPriority
```



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

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

### spawn

```rust
fn spawn<Fut>(self: &Self, future: Fut) -> DispatcherTask<<Fut as >::Output>
where Fut: Future + Send + 'static,
      <Fut as >::Output: Send + 'static
```

Runs `future` on the dispatcher thread. Can be called from any
thread.

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

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

### spawn_local

```rust
fn spawn_local<Fut>(self: &Self, future: Fut) -> DispatcherTask<<Fut as >::Output>
where Fut: Future + 'static,
      <Fut as >::Output: 'static
```

Runs a future that is not `Send` on the dispatcher thread.
## Panics
Panics when called from a thread other than the dispatcher thread.

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

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

### start_local

```rust
fn start_local<Fut>(self: &Self, future: Fut) -> DispatcherTask<<Fut as >::Output>
where Fut: Future + 'static,
      <Fut as >::Output: 'static
```

Starts a future that is not `Send` on the dispatcher thread the way
calling an asynchronous method does: the future is polled for the
first time before this returns, so it runs up to its first pending
await right away (and the returned task is already complete if there
is none). Afterwards it is resumed from dispatcher jobs at the
priority of the scheduler.
## Panics
Panics when called from a thread other than the dispatcher thread.

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

## 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`
- `ToOwned`
- `ErasedDestructor`
- `IntoEither`
- `Clone`

## Availability

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