# FerroScheduler

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-reactiveui-controls/struct-ferroscheduler/

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

```rust
struct FerroScheduler
```

The scheduler of the user-interface thread: it runs its work on the thread of a
`Dispatcher`, at a priority, and coalesces the work scheduled before the dispatcher runs it
into one job of the dispatcher (a drain).

Work runs in the jobs of the dispatcher, never inline in `schedule`;
disposing scheduled work that has not started drops it, and disposing work that has started
disposes what the work returned. Delayed work waits on a `DispatcherTimer`.

`RxSchedulers::set_main_thread_scheduler`
takes `FerroScheduler::instance` when the application uses ReactiveUI.

Deviation (DEVIATIONS.md, ReactiveUI controls): the work is not `Send`, as the observables of
the port are not (`docs/porting/reactive.md`, section 5.1): the scheduler posts its drains with
`Dispatcher::post_local` and is used on the thread of its dispatcher, where upstream may
schedule from any thread. The shared instance and the schedulers of other dispatchers are kept
per thread. The constructor that takes the posting and the timers of a test (internal upstream)
is not ported.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/ferro_scheduler.rs#L44)

## Members

- [`new`](#function-new)
- [`with_dispatcher`](#function-with_dispatcher)
- [`with_priority`](#function-with_priority)
- [`instance`](#function-instance)
- [`for_dispatcher`](#function-for_dispatcher)
- [`dispatcher`](#function-dispatcher)
- [`priority`](#function-priority)
- [`check_access`](#function-check_access)
- [`install_on_ui_thread`](#function-install_on_ui_thread)

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

### new

```rust
fn new() -> Rc<Self>
```

A scheduler of the dispatcher of the user-interface thread at
`DispatcherPriority::BACKGROUND` (`new FerroScheduler(Dispatcher.UIThread)`). Most code
takes the shared one, `instance`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/ferro_scheduler.rs#L65)

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

### with_dispatcher

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

A scheduler of `dispatcher` at `DispatcherPriority::BACKGROUND` (`FerroScheduler(Dispatcher)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/ferro_scheduler.rs#L70)

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

### with_priority

```rust
fn with_priority(dispatcher: &Arc<Dispatcher>, priority: DispatcherPriority) -> Rc<Self>
```

A scheduler of `dispatcher` that posts its drains and starts its timers at `priority`
(`FerroScheduler(Dispatcher, DispatcherPriority)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/ferro_scheduler.rs#L76)

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

### instance

```rust
fn instance() -> Rc<Self>
```

The shared scheduler of the dispatcher of the user-interface thread, at
`DispatcherPriority::BACKGROUND` (`Instance`). A new one is made when the dispatcher of
the user-interface thread is replaced (the dispatcher of a unit test).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/ferro_scheduler.rs#L89)

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

### for_dispatcher

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

The scheduler of `dispatcher`, created once per dispatcher: `instance`
for its own dispatcher, otherwise one scheduler per dispatcher at
`DispatcherPriority::BACKGROUND` (`For(Dispatcher)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/ferro_scheduler.rs#L106)

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

### dispatcher

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

The dispatcher the scheduler runs its work on (`Dispatcher`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/ferro_scheduler.rs#L123)

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

### priority

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

The priority of the drains and of the timers of delayed work (`Priority`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/ferro_scheduler.rs#L128)

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

### check_access

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

Whether the calling thread is the thread of the dispatcher, which may run the work of the
scheduler inline (`CheckAccess`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/ferro_scheduler.rs#L134)

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

### install_on_ui_thread

```rust
fn install_on_ui_thread()
```

Makes the synchronization context of the dispatcher of the user-interface thread the
synchronization context of that thread (`SynchronizationContext.SetSynchronizationContext`),
which also makes it the thread poster of the thread
(`ferroui_system::task::set_thread_schedule`): a task of the user-interface
thread woken from another thread is resumed through the dispatcher.

The context is the dispatcher's `FerroSynchronizationContext` of the thread (installed if it
has none yet), at `DispatcherPriority::NORMAL` when the thread has none. Nothing changes
when that context is already the current one.

Deprecated: a dispatcher is the schedule of its thread from its start, so the wakes from
other threads reach it without this, and the dispatcher at the priority of the running job
is the current schedule of `ferroui-system` (`ferroui_system::task::current_schedule`),
which the tasks and the reactive libraries read. The code that runs outside of a job takes
the priority that `Dispatcher::set_current_priority` sets, which the application sets to
Normal.
## Panics
Panics when the calling thread is not the user-interface thread.

> **Deprecated since 0.5.0.** the dispatcher is the schedule of its thread and of its jobs (`ferroui_system::task::current_schedule`); nothing is to be installed

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI.Controls/ferro_scheduler.rs#L166)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `ErasedDestructor`
- `IntoEither`
- `Debug`
- [`IScheduler`](/docs/0.5.0/api/ferroui-reactive/concurrency/trait-ischeduler/)
- [`IThreadAffineSequencer`](/docs/0.5.0/api/ferroui-reactiveui/trait-ithreadaffinesequencer/)

## Availability

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