# SynchronizationContextScheduler

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-reactive/concurrency/struct-synchronizationcontextscheduler/

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

```rust
struct SynchronizationContextScheduler
```

Schedules work on a context (`SynchronizationContextScheduler`), a `Schedule` of
`ferroui-system`: each work is posted to it with `Schedule::schedule_local`, unless the
scheduler does not always post and the schedule is the current one of the thread
(`ferroui_system::task::current_schedule`), which runs it at once.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/concurrency/synchronization_context_scheduler.rs#L100)

## Members

- [`with_schedule`](#function-with_schedule)
- [`with_schedule_and_always_post`](#function-with_schedule_and_always_post)
- [`new`](#function-new)
- [`with_always_post`](#function-with_always_post)
- [`context_schedule`](#function-context_schedule)
- [`context`](#function-context)

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

### with_schedule

```rust
fn with_schedule(schedule: Arc<dyn Schedule>) -> Rc<Self>
```

A scheduler that posts all its work to `schedule`
(`SynchronizationContextScheduler(SynchronizationContext)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/concurrency/synchronization_context_scheduler.rs#L109)

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

### with_schedule_and_always_post

```rust
fn with_schedule_and_always_post(schedule: Arc<dyn Schedule>, always_post: bool) -> Rc<Self>
```

A scheduler of `schedule` that runs its work at once when `always_post` is false and
`schedule` is the current schedule of the thread
(`SynchronizationContextScheduler(SynchronizationContext, bool alwaysPost)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/concurrency/synchronization_context_scheduler.rs#L116)

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

### new

```rust
fn new(context: Arc<dyn SynchronizationContext>) -> Rc<Self>
```

A scheduler that posts all its work to `context`
(`SynchronizationContextScheduler(SynchronizationContext)`).

> **Deprecated since 0.5.0.** use `SynchronizationContextScheduler::with_schedule`

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/concurrency/synchronization_context_scheduler.rs#L123)

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

### with_always_post

```rust
fn with_always_post(context: Arc<dyn SynchronizationContext>, always_post: bool) -> Rc<Self>
```

A scheduler of `context` that runs its work at once when `always_post` is false and
`context` is the current context of the thread
(`SynchronizationContextScheduler(SynchronizationContext, bool alwaysPost)`).

> **Deprecated since 0.5.0.** use `SynchronizationContextScheduler::with_schedule_and_always_post`

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/concurrency/synchronization_context_scheduler.rs#L131)

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

### context_schedule

```rust
fn context_schedule(self: &Self) -> Option<&Arc<dyn Schedule>>
```

The schedule the scheduler posts to (its context), `None` for a scheduler of a deprecated
context. Not named `schedule`, which is the member of `IScheduler`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/concurrency/synchronization_context_scheduler.rs#L141)

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

### context

```rust
fn context(self: &Self) -> &Arc<dyn SynchronizationContext>
```

The context the scheduler posts to.
## Panics
When the scheduler was made with a schedule (`with_schedule`).

> **Deprecated since 0.5.0.** use `SynchronizationContextScheduler::context_schedule`

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/concurrency/synchronization_context_scheduler.rs#L153)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- [`IScheduler`](/docs/0.5.0/api/ferroui-reactive/concurrency/trait-ischeduler/)

## Availability

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