# DispatcherOperation

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

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

```rust
struct DispatcherOperation<R = ()>
```

Represents an object used to interact with a job that has been posted to
the [`Dispatcher`](/docs/0.5.0/api/ferroui-base/threading/struct-dispatcher/) queue.

The handle can be cloned and sent to other threads. It is also a
`Future` that resolves when the operation has completed
(`Ok(result)`) or has been aborted (`Err(Canceled)`).

A panic raised by the callback is the equivalent of an exception in the
reference implementation: it is captured when the callback runs and
re-raised by `wait`, `result` and when the
future is polled.

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

## Members

- [`status`](#function-status)
- [`dispatcher`](#function-dispatcher)
- [`priority`](#function-priority)
- [`set_priority`](#function-set_priority)
- [`aborted`](#function-aborted)
- [`completed`](#function-completed)
- [`abort`](#function-abort)
- [`wait`](#function-wait)
- [`wait_with_timeout`](#function-wait_with_timeout)
- [`result`](#function-result)

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

### status

```rust
fn status(self: &Self) -> DispatcherOperationStatus
```

The current status of the operation.

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

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

### dispatcher

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

The dispatcher the operation was queued on.

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

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

### priority

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



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

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

### set_priority

```rust
fn set_priority(self: &Self, value: DispatcherPriority)
```

Changes the priority of the operation. A queued operation keeps its
position relative to the other operations of the new priority.

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

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

### aborted

```rust
fn aborted(self: &Self, handler: impl Fn() -> () + Send + Sync + 'static) -> Rc<dyn IDisposable>
```

An event that is raised when the operation is aborted or canceled.

The handler runs on the thread that aborts the operation.

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

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

### completed

```rust
fn completed(self: &Self, handler: impl Fn() -> () + Send + Sync + 'static) -> Rc<dyn IDisposable>
```

An event that is raised when the operation completes.

The handler runs on the dispatcher thread.

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

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

### abort

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

Removes a pending operation from the queue. Returns `false` when the
operation is no longer pending.

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

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

### wait

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

Waits for this operation to complete.

On the dispatcher thread this pumps the queue (nesting a frame when
the operation has a background priority and the platform supports run
loops). On any other thread it blocks.

Returns `Err` when the operation was aborted.
## Panics
Re-raises the panic of the callback. Panics when called on the
dispatcher thread for the operation that is currently executing.

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

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

### wait_with_timeout

```rust
fn wait_with_timeout(self: &Self, timeout: Duration) -> Result<bool, Canceled>
```

Waits for this operation to complete, for at most `timeout`.

Returns `Ok(true)` when the operation completed in time, `Ok(false)`
when it is still pending or executing after `timeout`, and `Err` when
it was aborted.

On the dispatcher thread this pumps the queue like
`wait` and measures the timeout with the dispatcher
clock; a nested frame (background priorities, where the platform
supports run loops) is left by a dispatcher timer. On any other
thread it blocks. A zero timeout only reports the current state.
## Panics
Re-raises the panic of the callback. Panics when called on the
dispatcher thread for the operation that is currently executing.

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

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

### result

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

Takes the result of the operation.

When the operation has not finished yet this blocks, which is only
supported on non-dispatcher threads.
## Panics
Re-raises the panic of the callback. Panics when the operation is not
finished and the calling thread is the dispatcher thread, when the
result has already been taken, and when the result of a local
operation is requested from another thread.

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

## 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`

## Availability

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