pub struct TaskPriorityQueue { /* private fields */ }Expand description
A priority queue for scheduling workflow tasks.
Implementations§
Source§impl TaskPriorityQueue
impl TaskPriorityQueue
Sourcepub fn with_aging_threshold(self, secs: u64) -> Self
pub fn with_aging_threshold(self, secs: u64) -> Self
Set the aging threshold (seconds of waiting before priority promotion).
Sourcepub fn enqueue(
&mut self,
task_id: impl Into<String>,
priority: PriorityLevel,
submitted_secs: u64,
) -> u64
pub fn enqueue( &mut self, task_id: impl Into<String>, priority: PriorityLevel, submitted_secs: u64, ) -> u64
Enqueue a task with the given priority and submission time.
Sourcepub fn enqueue_with_deadline(
&mut self,
task_id: impl Into<String>,
priority: PriorityLevel,
submitted_secs: u64,
deadline_secs: u64,
) -> u64
pub fn enqueue_with_deadline( &mut self, task_id: impl Into<String>, priority: PriorityLevel, submitted_secs: u64, deadline_secs: u64, ) -> u64
Enqueue a task with a deadline.
Sourcepub fn dequeue(&mut self) -> Option<PriorityEntry>
pub fn dequeue(&mut self) -> Option<PriorityEntry>
Dequeue the highest-priority task.
Sourcepub fn peek(&self) -> Option<&PriorityEntry>
pub fn peek(&self) -> Option<&PriorityEntry>
Peek at the highest-priority task without removing it.
Sourcepub fn apply_aging(&mut self, now_secs: u64)
pub fn apply_aging(&mut self, now_secs: u64)
Apply priority aging: promote tasks that have been waiting longer than the threshold.
This drains and rebuilds the heap, so call sparingly.
Sourcepub fn drain_overdue(&mut self, now_secs: u64) -> Vec<PriorityEntry>
pub fn drain_overdue(&mut self, now_secs: u64) -> Vec<PriorityEntry>
Drain all overdue tasks (past their deadline).
Sourcepub fn count_by_priority(&self) -> [usize; 4]
pub fn count_by_priority(&self) -> [usize; 4]
Count tasks at each priority level.
Trait Implementations§
Source§impl Debug for TaskPriorityQueue
impl Debug for TaskPriorityQueue
Auto Trait Implementations§
impl Freeze for TaskPriorityQueue
impl RefUnwindSafe for TaskPriorityQueue
impl Send for TaskPriorityQueue
impl Sync for TaskPriorityQueue
impl Unpin for TaskPriorityQueue
impl UnsafeUnpin for TaskPriorityQueue
impl UnwindSafe for TaskPriorityQueue
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more