Skip to main content

Queue

Trait Queue 

Source
pub trait Queue<TKey, TMsg>: Send + 'static
where TKey: JobKey, TMsg: Message,
{ // Required methods fn len(&self) -> usize; fn is_empty(&self) -> bool; fn pop_front(&mut self) -> Option<Job<TKey, TMsg>>; fn discard_oldest(&mut self) -> Option<Job<TKey, TMsg>>; fn peek(&self) -> Option<&Job<TKey, TMsg>>; fn push_back(&mut self, job: Job<TKey, TMsg>); fn remove_expired_items( &mut self, discard_handler: &Option<Arc<dyn DiscardHandler<TKey, TMsg>>>, ) -> usize; // Provided method fn is_job_discardable(&self, _key: &TKey) -> bool { ... } }
Expand description

Implementation of backing queue for factory messages when workers are all busy

Required Methods§

Source

fn len(&self) -> usize

Retrieve the size of the factory’s queue

Source

fn is_empty(&self) -> bool

Check if the queue is empty

Source

fn pop_front(&mut self) -> Option<Job<TKey, TMsg>>

Pop the next message from the front of the queue

Source

fn discard_oldest(&mut self) -> Option<Job<TKey, TMsg>>

Try and discard a message according to the queue semantics in an overload scenario (e.g. lowest priority if priority queueing). In a basic queueing scenario, this is equivalent to pop_front

Source

fn peek(&self) -> Option<&Job<TKey, TMsg>>

Peek an item from the head of the queue

Source

fn push_back(&mut self, job: Job<TKey, TMsg>)

Push an item to the back of the queue

Source

fn remove_expired_items( &mut self, discard_handler: &Option<Arc<dyn DiscardHandler<TKey, TMsg>>>, ) -> usize

Remove expired items from the queue

Returns the number of elements removed from the queue

Provided Methods§

Source

fn is_job_discardable(&self, _key: &TKey) -> bool

Determine if a given job can be discarded. Default is true for all jobs.

This can be overridden to customize discard semantics.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<TKey, TMsg, TPriority, TPriorityManager, const NUM_PRIORITIES: usize> Queue<TKey, TMsg> for PriorityQueue<TKey, TMsg, TPriority, TPriorityManager, NUM_PRIORITIES>
where TKey: JobKey, TMsg: Message, TPriority: Priority, TPriorityManager: PriorityManager<TKey, TPriority>,

Source§

impl<TKey, TMsg> Queue<TKey, TMsg> for DefaultQueue<TKey, TMsg>
where TKey: JobKey, TMsg: Message,