Skip to main content

Priority

Type Alias Priority 

Source
pub type Priority = Priority;
Expand description

Task priority for scheduling hints.

This is a re-export of the priority crate’s Priority type, allowing executors to make scheduling decisions based on task priority.

Aliased Type§

pub enum Priority {
    UserInteractive,
    UserInitiated,
    Utility,
    Background,
    Unknown,
}

Variants§

§

UserInteractive

The task runs at UI priority.

Generally, we expect this task to paint the screen or respond to user input as soon as possible.

In systems with a single-threaded UI, the task runs on the UI thread. Work performed at this priority may block the UI thread.

§

UserInitiated

The task runs at a high priority.

Use this priority for tasks that respond to user input, and expect to complete quickly, before the user switches focus (e.g. on the order of a second).

Use this priority for tasks where the user is likely waiting on the input.

§

Utility

This task runs at a medium priority.

Use this priority for tasks with expected such that the user may switch focus before they complete (e.g. on the order of a 10+ seconds).

Use this priority for tasks where we might display a progress bar and ideally the user can move onto other work during completion.

§

Background

This task runs at a low priority.

Use this priority for tasks that are not time-sensitive, and can run in the background.

Use this priority for tasks that are not visible to the user, and do not require user input.

§

Unknown

The priority of the task is not known.

Avoid the use of this value. It should be used in cases where the priority cannot be reasonably determined.