#[non_exhaustive]pub enum Priority {
Default,
Background,
UserInitiated,
UserInteractive,
Utility,
}
Expand description
Task execution priority levels for controlling scheduler behavior.
These priority levels map to platform-native scheduling priorities, allowing fine-grained control over task execution order and resource allocation.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Default
Standard priority level for most application tasks.
This is the default priority that provides balanced execution suitable for general-purpose async operations.
Background
Lower priority for background tasks and non-critical operations.
Background tasks yield CPU time to higher-priority tasks and are ideal for operations like cleanup, logging, or data processing that don’t require immediate completion.
UserInitiated
Higher priority for user-initiated tasks that require prompt execution. This priority is suitable for tasks that directly impact user experience, such as responding to user input or updating the UI.
UserInteractive
Highest priority for tasks that require immediate attention to maintain application responsiveness. This priority should be reserved for critical operations that must complete as soon as possible, such as rendering UI updates or handling real-time data.
Utility
Lowest priority for tasks that can be deferred until the system is idle. This priority is suitable for maintenance tasks, prefetching data, or other operations that do not need to run immediately and can wait until the system is less busy.