FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    DispatcherOperation

    struct · ferroui-base · v0.5.0

    struct DispatcherOperation<R = ()>
    

    Represents an object used to interact with a job that has been posted to the 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

    Members

    status

    fn status(self: &Self) -> DispatcherOperationStatus
    

    The current status of the operation.

    Source

    dispatcher

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

    The dispatcher the operation was queued on.

    Source

    priority

    fn priority(self: &Self) -> DispatcherPriority
    

    Source

    set_priority

    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

    aborted

    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

    completed

    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

    abort

    fn abort(self: &Self) -> bool
    

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

    Source

    wait

    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

    wait_with_timeout

    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

    result

    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

    Trait implementations

    • Send
    • Sync
    • Freeze
    • UnsafeUnpin
    • Unpin
    • UnwindSafe
    • RefUnwindSafe
    • 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.