Skip to main content

Queue

Struct Queue 

Source
pub struct Queue<SI, SM, SO, T>
where SI: QueueStrategy + 'static, SM: QueueStrategy, SO: QueueStrategy + 'static, T: 'static,
{ /* private fields */ }
Expand description

Represents a bounded queue by using the specified strategies for enqueueing (input), SI, internal storing (in memory), SM, and dequeueing (output), SO, where T denotes the type of items stored in the queue.

Implementations§

Source§

impl<SI, SM, SO, T> Queue<SI, SM, SO, T>
where SI: QueueStrategy + Clone + 'static, SM: QueueStrategy + Clone + 'static, SO: QueueStrategy + Clone + 'static, T: Clone + 'static,

Source

pub fn new( enqueue_strategy: SI, storing_strategy: SM, dequeue_strategy: SO, max_count: isize, ) -> NewQueue<SI, SM, SO, T>

Create a new bounded queue by the specified strategies and capacity.

Source

pub fn max_count(&self) -> isize

Return the queue capacity, i.e. its maximum size.

Source

pub fn is_empty(queue: Grc<Self>) -> impl Event<Item = bool> + Clone

Test whether the queue is empty.

Source

pub fn is_empty_changed( queue: Grc<Self>, ) -> impl Observable<Message = bool> + Clone

Notifies when the is_empty property changes.

Source

pub fn is_empty_changed_(&self) -> impl Observable<Message = ()> + Clone

Notifies when the is_empty property changes.

Source

pub fn is_full(queue: Grc<Self>) -> impl Event<Item = bool> + Clone

Test whether the queue is full.

Source

pub fn is_full_changed( queue: Grc<Self>, ) -> impl Observable<Message = bool> + Clone

Notifies when the is_full property changes.

Source

pub fn is_full_changed_(&self) -> impl Observable<Message = ()> + Clone

Notifies when the is_full property changes.

Source

pub fn count(queue: Grc<Self>) -> impl Event<Item = isize> + Clone

Return the current queue size.

Source

pub fn count_stats( queue: Grc<Self>, ) -> impl Event<Item = TimingStats<isize>> + Clone

Return the statistics for the queue size.

Source

pub fn count_changed( queue: Grc<Self>, ) -> impl Observable<Message = isize> + Clone

Notifies when the count property changes.

Source

pub fn count_changed_(&self) -> impl Observable<Message = ()> + Clone

Notifies when the count property changes.

Source

pub fn enqueue_count(queue: Grc<Self>) -> impl Event<Item = isize> + Clone

Return the total number of enqueue operations, including those ones that have failed due to full capacity.

Source

pub fn enqueue_count_changed( queue: Grc<Self>, ) -> impl Observable<Message = isize> + Clone

Notifies when the enqueue_count property changes.

Source

pub fn enqueue_count_changed_(&self) -> impl Observable<Message = ()> + Clone

Notifies when the enqueue_count property changes.

Source

pub fn enqueue_lost_count(queue: Grc<Self>) -> impl Event<Item = isize> + Clone

Return the total number of items that could not be enqueued due to full capacity.

Source

pub fn enqueue_lost_count_changed( queue: Grc<Self>, ) -> impl Observable<Message = isize> + Clone

Notifies when the enqueue_lost_count property changes.

Source

pub fn enqueue_lost_count_changed_( &self, ) -> impl Observable<Message = ()> + Clone

Notifies when the enqueue_lost_count property changes.

Source

pub fn enqueue_store_count(queue: Grc<Self>) -> impl Event<Item = isize> + Clone

Return the total number of input items that were stored.

Source

pub fn enqueue_store_count_changed( queue: Grc<Self>, ) -> impl Observable<Message = isize> + Clone

Notifies when the enqueue_store_count property changes.

Source

pub fn enqueue_store_count_changed_( &self, ) -> impl Observable<Message = ()> + Clone

Notifies when the enqueue_store_count property changes.

Source

pub fn dequeue_count(queue: Grc<Self>) -> impl Event<Item = isize> + Clone

Return the total number of requests to dequeue the items.

Source

pub fn dequeue_count_changed( queue: Grc<Self>, ) -> impl Observable<Message = isize> + Clone

Notifies when the dequeue_count property changes.

Source

pub fn dequeue_count_changed_(&self) -> impl Observable<Message = ()> + Clone

Notifies when the dequeue_count property changes.

Source

pub fn dequeue_extract_count( queue: Grc<Self>, ) -> impl Event<Item = isize> + Clone

Return the total number of items that were extracted from the queue with help of dequeue operations.

Source

pub fn dequeue_extract_count_changed( queue: Grc<Self>, ) -> impl Observable<Message = isize> + Clone

Notifies when the dequeue_extract_count property changes.

Source

pub fn dequeue_extract_count_changed_( &self, ) -> impl Observable<Message = ()> + Clone

Notifies when the dequeue_extract_count property changes.

Source

pub fn load_factor(queue: Grc<Self>) -> impl Event<Item = f64> + Clone

Return the load factor: the queue size divided by its capacity, i.e. maximum size.

Source

pub fn load_factor_changed( queue: Grc<Self>, ) -> impl Observable<Message = f64> + Clone

Notifies when the load_factor property changes.

Source

pub fn load_factor_changed_(&self) -> impl Observable<Message = ()> + Clone

Notifies when the load_factor property changes.

Source

pub fn enqueue_rate(queue: Grc<Self>) -> impl Event<Item = f64> + Clone

Return the rate of input items that were enqueued: how many items per time.

Source

pub fn store_rate(queue: Grc<Self>) -> impl Event<Item = f64> + Clone

Return the rate of input items that were stored: how many items per time.

Source

pub fn dequeue_rate(queue: Grc<Self>) -> impl Event<Item = f64> + Clone

Return the rate of requests for dequeueing the items: how many items per time. It does not include the failed attempts to dequeue immediately without suspension.

Source

pub fn dequeue_extract_rate(queue: Grc<Self>) -> impl Event<Item = f64> + Clone

Return the rate of output items that were actually extracted from the queue: how many items per time.

Source

pub fn wait_time( queue: Grc<Self>, ) -> impl Event<Item = SamplingStats<f64>> + Clone

Return the wait time from the time at which the item was stored in the queue to the time at which it was dequeued.

Source

pub fn wait_time_changed( queue: Grc<Self>, ) -> impl Observable<Message = SamplingStats<f64>> + Clone

Notifies when the wait_time property changes.

Source

pub fn wait_time_changed_(&self) -> impl Observable<Message = ()> + Clone

Notifies when the wait_time property changes.

Source

pub fn total_wait_time( queue: Grc<Self>, ) -> impl Event<Item = SamplingStats<f64>> + Clone

Return the total wait time from the time at which the enqueue operation was initiated to the time at which the item was dequeued.

In some sense, total_wait_time == enqueue_wait_time + wait_time.

Source

pub fn total_wait_time_changed( queue: Grc<Self>, ) -> impl Observable<Message = SamplingStats<f64>> + Clone

Notifies when the total_wait_time property changes.

Source

pub fn total_wait_time_changed_(&self) -> impl Observable<Message = ()> + Clone

Notifies when the total_wait_time property changes.

Source

pub fn enqueue_wait_time( queue: Grc<Self>, ) -> impl Event<Item = SamplingStats<f64>> + Clone

Return the enqueue wait time from the time at which the enqueue operation was initiated to the time at which the item was stored in the queue.

Source

pub fn enqueue_wait_time_changed( queue: Grc<Self>, ) -> impl Observable<Message = SamplingStats<f64>> + Clone

Notifies when the enqueue_wait_time property changes.

Source

pub fn enqueue_wait_time_changed_( &self, ) -> impl Observable<Message = ()> + Clone

Notifies when the enqueue_wait_time property changes.

Source

pub fn dequeue_wait_time( queue: Grc<Self>, ) -> impl Event<Item = SamplingStats<f64>> + Clone

Return the dequeue wait time from the time at which the dequeue request was made to the time at which the corresponding item was actually dequeued.

Source

pub fn dequeue_wait_time_changed( queue: Grc<Self>, ) -> impl Observable<Message = SamplingStats<f64>> + Clone

Notifies when the dequeue_wait_time property changes.

Source

pub fn dequeue_wait_time_changed_( &self, ) -> impl Observable<Message = ()> + Clone

Notifies when the dequeue_wait_time property changes.

Source

pub fn rate(queue: Grc<Self>) -> impl Event<Item = f64> + Clone

Return a long-term average queue rate calculated as the average queue size divided by the average wait time.

This value may be less than the actual arrival rate as the queue is bounded and new arrivals may be blocked while the queue remains full.

Source

pub fn rate_changed(queue: Grc<Self>) -> impl Observable<Message = f64> + Clone

Notifies when the rate property changes.

Source

pub fn rate_changed_(&self) -> impl Observable<Message = ()> + Clone

Notifies when the rate property changes.

Source

pub fn dequeue(queue: Grc<Self>) -> impl Process<Item = T> + Clone

Dequeue by suspending the process if the queue is empty.

Source

pub fn dequeue_with_output_priority( queue: Grc<Self>, po: SO::Priority, ) -> impl Process<Item = T> + Clone
where SO::Priority: Clone,

Dequeue with output prioerity by suspending the process if the queue is empty.

Source

pub fn try_dequeue(queue: Grc<Self>) -> impl Event<Item = Option<T>> + Clone

Try to dequeue immediately.

Source

pub fn delete(queue: Grc<Self>, item: T) -> impl Event<Item = bool> + Clone
where T: PartialEq,

Remove the item from the queue and return a flag indicating whether the item was found and actually removed.

Source

pub fn delete_(queue: Grc<Self>, item: T) -> impl Event<Item = ()> + Clone
where T: PartialEq,

Remove the specified item from the queue.

Source

pub fn delete_by<F>( queue: Grc<Self>, pred: F, ) -> impl Event<Item = Option<T>> + Clone
where F: Fn(&T) -> bool + Clone + 'static,

Remove an item satisfying the specified predicate and return the item if found.

Source

pub fn exists<F>(queue: Grc<Self>, pred: F) -> impl Event<Item = bool> + Clone
where F: Fn(&T) -> bool + Clone + 'static,

Test whether there is an item satisfying the specified predicate.

Source

pub fn find<F>( queue: Grc<Self>, pred: F, ) -> impl Event<Item = Option<T>> + Clone
where F: Fn(&T) -> bool + Clone + 'static, T: Clone,

Find an item satisfying the specified predicate.

Source

pub fn clear(queue: Grc<Self>) -> impl Event<Item = ()> + Clone

Clear the queue.

Source

pub fn enqueue(queue: Grc<Self>, item: T) -> impl Process<Item = ()> + Clone

Enqueue the item by suspending the process if the queue is full.

Source

pub fn enqueue_with_input_priority( queue: Grc<Self>, pi: SI::Priority, item: T, ) -> impl Process<Item = ()> + Clone
where SI::Priority: Clone,

Enqueue the item with input priority by suspending the process if the queue is full.

Source

pub fn enqueue_with_storing_priority( queue: Grc<Self>, pm: SM::Priority, item: T, ) -> impl Process<Item = ()> + Clone
where SM::Priority: Clone,

Enqueue the item with storing priority by suspending the process if the queue is full.

Source

pub fn enqueue_with_input_and_storing_priorities( queue: Grc<Self>, pi: SI::Priority, pm: SM::Priority, item: T, ) -> impl Process<Item = ()> + Clone
where SI::Priority: Clone, SM::Priority: Clone,

Enqueue the item with input and storing priorities by suspending the process if the queue is full.

Source

pub fn try_enqueue(queue: Grc<Self>, item: T) -> impl Event<Item = bool> + Clone

Try to enqueue the item. Return false within Event computation if the queue is full.

Source

pub fn try_enqueue_with_storing_priority( queue: Grc<Self>, pm: SM::Priority, item: T, ) -> impl Event<Item = bool> + Clone
where SM::Priority: Clone,

Try to enqueue the item with storing priority. Return false within Event computation if the queue is full.

Source

pub fn enqueue_or_lose( queue: Grc<Self>, item: T, ) -> impl Event<Item = bool> + Clone

Try to enqueue the item. If the queue is full then the item will be counted as lost and false will be returned.

Source

pub fn enqueue_with_storing_priority_or_lose( queue: Grc<Self>, pm: SM::Priority, item: T, ) -> impl Event<Item = bool> + Clone
where SM::Priority: Clone,

Try to enqueue the item with storing piority. If the queue is full then the item will be counted as lost and false will be returned.

Source

pub fn enqueue_or_lose_( queue: Grc<Self>, item: T, ) -> impl Event<Item = ()> + Clone

Try to enqueue the item. If the queue is full then the item will be counted as lost.

Source

pub fn enqueue_with_storing_priority_or_lose_( queue: Grc<Self>, pm: SM::Priority, item: T, ) -> impl Event<Item = ()> + Clone
where SM::Priority: Clone,

Try to enqueue the item with storing priority. If the queue is full then the item will be counted as lost.

Source

pub fn enqueue_initiated(&self) -> impl Observable<Message = T> + Clone

Notifies when the enqueue operation is initiated.

Source

pub fn enqueue_stored(&self) -> impl Observable<Message = T> + Clone

Notifies when the item to be enqueued is stored.

Source

pub fn enqueue_lost(&self) -> impl Observable<Message = T> + Clone

Notifies when the item that would have to be enqueued is lost.

Source

pub fn dequeue_requested(&self) -> impl Observable<Message = ()> + Clone

Notifies when the dequeue operation is requested for.

Source

pub fn dequeue_extracted(&self) -> impl Observable<Message = T> + Clone

Notifies when the item is dequeued.

Source

pub fn changed_(&self) -> impl Observable<Message = ()> + Clone

Notifies whenever any property changes.

Source

pub fn reset(queue: Grc<Self>) -> impl Event<Item = ()> + Clone

Reset the statistics.

Source

pub fn wait_while_full(queue: Grc<Self>) -> impl Process<Item = ()> + Clone

Wait while the queue is full.

Auto Trait Implementations§

§

impl<SI, SM, SO, T> !Freeze for Queue<SI, SM, SO, T>

§

impl<SI, SM, SO, T> !RefUnwindSafe for Queue<SI, SM, SO, T>

§

impl<SI, SM, SO, T> !Send for Queue<SI, SM, SO, T>

§

impl<SI, SM, SO, T> !Sync for Queue<SI, SM, SO, T>

§

impl<SI, SM, SO, T> !UnwindSafe for Queue<SI, SM, SO, T>

§

impl<SI, SM, SO, T> Unpin for Queue<SI, SM, SO, T>

§

impl<SI, SM, SO, T> UnsafeUnpin for Queue<SI, SM, SO, T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V