pub struct TaskQueue { /* private fields */ }Expand description
A priority-based task queue for distributed task scheduling.
Tasks are dequeued in priority order; within the same priority, tasks follow FIFO ordering based on their enqueue sequence.
Implementations§
Source§impl TaskQueue
impl TaskQueue
Sourcepub fn with_capacity(max_capacity: usize) -> Self
pub fn with_capacity(max_capacity: usize) -> Self
Creates a new task queue with a capacity limit.
Sourcepub fn enqueue(&mut self, task: DistributedTask) -> bool
pub fn enqueue(&mut self, task: DistributedTask) -> bool
Enqueues a task. Returns false if the queue is at capacity.
Sourcepub fn dequeue(&mut self) -> Option<DistributedTask>
pub fn dequeue(&mut self) -> Option<DistributedTask>
Dequeues the highest-priority task.
Returns None if the queue is empty.
Sourcepub fn peek(&self) -> Option<&DistributedTask>
pub fn peek(&self) -> Option<&DistributedTask>
Peeks at the highest-priority task without removing it.
Sourcepub fn total_enqueued(&self) -> u64
pub fn total_enqueued(&self) -> u64
Returns total tasks ever enqueued.
Sourcepub fn total_dequeued(&self) -> u64
pub fn total_dequeued(&self) -> u64
Returns total tasks ever dequeued.
Sourcepub fn drain(&mut self) -> Vec<DistributedTask>
pub fn drain(&mut self) -> Vec<DistributedTask>
Drains all tasks from the queue in priority order.
Sourcepub fn remove_expired(&mut self, now: i64) -> Vec<DistributedTask>
pub fn remove_expired(&mut self, now: i64) -> Vec<DistributedTask>
Removes tasks that have passed their deadline.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TaskQueue
impl RefUnwindSafe for TaskQueue
impl Send for TaskQueue
impl Sync for TaskQueue
impl Unpin for TaskQueue
impl UnsafeUnpin for TaskQueue
impl UnwindSafe for TaskQueue
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request