# VirtualTimeScheduler

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

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

```rust
struct VirtualTimeScheduler<C: VirtualTimeClock>
```

A scheduler of virtual time (`VirtualTimeScheduler<TAbsolute, TRelative>`): work runs when the
clock is advanced to its due time (`start`, `advance_to`, `advance_by`), in the order of due
times and, for equal ones, in the order it was scheduled.

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

## Members

- [`historical`](#function-historical)
- [`historical_at`](#function-historical_at)
- [`new`](#function-new)
- [`clock`](#function-clock)
- [`set_clock`](#function-set_clock)
- [`is_enabled`](#function-is_enabled)
- [`schedule_absolute`](#function-schedule_absolute)
- [`schedule_relative`](#function-schedule_relative)
- [`start`](#function-start)
- [`stop`](#function-stop)
- [`advance_to`](#function-advance_to)
- [`advance_by`](#function-advance_by)
- [`sleep`](#function-sleep)

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

### historical

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

A historical scheduler with its clock at the epoch of the system time.

Deviation (DEVIATIONS.md, Reactive): upstream starts at `DateTimeOffset.MinValue`; the
system time has no such minimum, and the epoch is the earliest time every platform has.

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

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

### historical_at

```rust
fn historical_at(initial_clock: SystemTime) -> Rc<Self>
```

A historical scheduler with its clock at `initial_clock`.

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

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

### new

```rust
fn new(initial_clock: <C as >::Absolute) -> Rc<Self>
```

A scheduler with its clock at `initial_clock`.

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

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

### clock

```rust
fn clock(self: &Self) -> <C as >::Absolute
```

The current time of the clock (`Clock`).

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

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

### set_clock

```rust
fn set_clock(self: &Self, clock: <C as >::Absolute)
```

Sets the clock (`Clock`'s protected setter), for derived schedulers.

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

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

### is_enabled

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

Whether the scheduler is running work (`IsEnabled`).

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

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

### schedule_absolute

```rust
fn schedule_absolute(self: &Self, due_time: <C as >::Absolute, action: ScheduledAction) -> Rc<dyn IDisposable>
```

Schedules work at an absolute virtual time (`ScheduleAbsolute`).

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

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

### schedule_relative

```rust
fn schedule_relative(self: &Self, due_time: <C as >::Relative, action: ScheduledAction) -> Rc<dyn IDisposable>
```

Schedules work at a virtual time relative to the clock (`ScheduleRelative`).

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

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

### start

```rust
fn start(self: &Self)
```

Runs the queued work, moving the clock to the due time of each, until there is none or the
scheduler is stopped (`Start`).

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

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

### stop

```rust
fn stop(self: &Self)
```

Stops the scheduler after the work that runs (`Stop`).

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

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

### advance_to

```rust
fn advance_to(self: &Self, time: <C as >::Absolute)
```

Runs the work due up to `time` and moves the clock to it (`AdvanceTo`). Panics when `time`
is before the clock or the scheduler is running, where upstream throws.

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

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

### advance_by

```rust
fn advance_by(self: &Self, time: <C as >::Relative)
```

Runs the work due within `time` from the clock and moves the clock by it (`AdvanceBy`).

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

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

### sleep

```rust
fn sleep(self: &Self, time: <C as >::Relative)
```

Moves the clock by `time` without running work (`Sleep`).

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

## 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/)
- [`IStopwatchProvider`](/docs/0.5.0/api/ferroui-reactive/concurrency/trait-istopwatchprovider/)

## Availability

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