pub struct Queue<SI, SM, SO, T>{ /* 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,
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,
Sourcepub fn new(
enqueue_strategy: SI,
storing_strategy: SM,
dequeue_strategy: SO,
max_count: isize,
) -> NewQueue<SI, SM, SO, T>
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.
Sourcepub fn is_empty(queue: Grc<Self>) -> impl Event<Item = bool> + Clone
pub fn is_empty(queue: Grc<Self>) -> impl Event<Item = bool> + Clone
Test whether the queue is empty.
Sourcepub fn is_empty_changed(
queue: Grc<Self>,
) -> impl Observable<Message = bool> + Clone
pub fn is_empty_changed( queue: Grc<Self>, ) -> impl Observable<Message = bool> + Clone
Notifies when the is_empty property changes.
Sourcepub fn is_empty_changed_(&self) -> impl Observable<Message = ()> + Clone
pub fn is_empty_changed_(&self) -> impl Observable<Message = ()> + Clone
Notifies when the is_empty property changes.
Sourcepub fn is_full(queue: Grc<Self>) -> impl Event<Item = bool> + Clone
pub fn is_full(queue: Grc<Self>) -> impl Event<Item = bool> + Clone
Test whether the queue is full.
Sourcepub fn is_full_changed(
queue: Grc<Self>,
) -> impl Observable<Message = bool> + Clone
pub fn is_full_changed( queue: Grc<Self>, ) -> impl Observable<Message = bool> + Clone
Notifies when the is_full property changes.
Sourcepub fn is_full_changed_(&self) -> impl Observable<Message = ()> + Clone
pub fn is_full_changed_(&self) -> impl Observable<Message = ()> + Clone
Notifies when the is_full property changes.
Sourcepub fn count(queue: Grc<Self>) -> impl Event<Item = isize> + Clone
pub fn count(queue: Grc<Self>) -> impl Event<Item = isize> + Clone
Return the current queue size.
Sourcepub fn count_stats(
queue: Grc<Self>,
) -> impl Event<Item = TimingStats<isize>> + Clone
pub fn count_stats( queue: Grc<Self>, ) -> impl Event<Item = TimingStats<isize>> + Clone
Return the statistics for the queue size.
Sourcepub fn count_changed(
queue: Grc<Self>,
) -> impl Observable<Message = isize> + Clone
pub fn count_changed( queue: Grc<Self>, ) -> impl Observable<Message = isize> + Clone
Notifies when the count property changes.
Sourcepub fn count_changed_(&self) -> impl Observable<Message = ()> + Clone
pub fn count_changed_(&self) -> impl Observable<Message = ()> + Clone
Notifies when the count property changes.
Sourcepub fn enqueue_count(queue: Grc<Self>) -> impl Event<Item = isize> + Clone
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.
Sourcepub fn enqueue_count_changed(
queue: Grc<Self>,
) -> impl Observable<Message = isize> + Clone
pub fn enqueue_count_changed( queue: Grc<Self>, ) -> impl Observable<Message = isize> + Clone
Notifies when the enqueue_count property changes.
Sourcepub fn enqueue_count_changed_(&self) -> impl Observable<Message = ()> + Clone
pub fn enqueue_count_changed_(&self) -> impl Observable<Message = ()> + Clone
Notifies when the enqueue_count property changes.
Sourcepub fn enqueue_lost_count(queue: Grc<Self>) -> impl Event<Item = isize> + Clone
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.
Sourcepub fn enqueue_lost_count_changed(
queue: Grc<Self>,
) -> impl Observable<Message = isize> + Clone
pub fn enqueue_lost_count_changed( queue: Grc<Self>, ) -> impl Observable<Message = isize> + Clone
Notifies when the enqueue_lost_count property changes.
Sourcepub fn enqueue_lost_count_changed_(
&self,
) -> impl Observable<Message = ()> + Clone
pub fn enqueue_lost_count_changed_( &self, ) -> impl Observable<Message = ()> + Clone
Notifies when the enqueue_lost_count property changes.
Sourcepub fn enqueue_store_count(queue: Grc<Self>) -> impl Event<Item = isize> + Clone
pub fn enqueue_store_count(queue: Grc<Self>) -> impl Event<Item = isize> + Clone
Return the total number of input items that were stored.
Sourcepub fn enqueue_store_count_changed(
queue: Grc<Self>,
) -> impl Observable<Message = isize> + Clone
pub fn enqueue_store_count_changed( queue: Grc<Self>, ) -> impl Observable<Message = isize> + Clone
Notifies when the enqueue_store_count property changes.
Sourcepub fn enqueue_store_count_changed_(
&self,
) -> impl Observable<Message = ()> + Clone
pub fn enqueue_store_count_changed_( &self, ) -> impl Observable<Message = ()> + Clone
Notifies when the enqueue_store_count property changes.
Sourcepub fn dequeue_count(queue: Grc<Self>) -> impl Event<Item = isize> + Clone
pub fn dequeue_count(queue: Grc<Self>) -> impl Event<Item = isize> + Clone
Return the total number of requests to dequeue the items.
Sourcepub fn dequeue_count_changed(
queue: Grc<Self>,
) -> impl Observable<Message = isize> + Clone
pub fn dequeue_count_changed( queue: Grc<Self>, ) -> impl Observable<Message = isize> + Clone
Notifies when the dequeue_count property changes.
Sourcepub fn dequeue_count_changed_(&self) -> impl Observable<Message = ()> + Clone
pub fn dequeue_count_changed_(&self) -> impl Observable<Message = ()> + Clone
Notifies when the dequeue_count property changes.
Sourcepub fn dequeue_extract_count(
queue: Grc<Self>,
) -> impl Event<Item = isize> + Clone
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.
Sourcepub fn dequeue_extract_count_changed(
queue: Grc<Self>,
) -> impl Observable<Message = isize> + Clone
pub fn dequeue_extract_count_changed( queue: Grc<Self>, ) -> impl Observable<Message = isize> + Clone
Notifies when the dequeue_extract_count property changes.
Sourcepub fn dequeue_extract_count_changed_(
&self,
) -> impl Observable<Message = ()> + Clone
pub fn dequeue_extract_count_changed_( &self, ) -> impl Observable<Message = ()> + Clone
Notifies when the dequeue_extract_count property changes.
Sourcepub fn load_factor(queue: Grc<Self>) -> impl Event<Item = f64> + Clone
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.
Sourcepub fn load_factor_changed(
queue: Grc<Self>,
) -> impl Observable<Message = f64> + Clone
pub fn load_factor_changed( queue: Grc<Self>, ) -> impl Observable<Message = f64> + Clone
Notifies when the load_factor property changes.
Sourcepub fn load_factor_changed_(&self) -> impl Observable<Message = ()> + Clone
pub fn load_factor_changed_(&self) -> impl Observable<Message = ()> + Clone
Notifies when the load_factor property changes.
Sourcepub fn enqueue_rate(queue: Grc<Self>) -> impl Event<Item = f64> + Clone
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.
Sourcepub fn store_rate(queue: Grc<Self>) -> impl Event<Item = f64> + Clone
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.
Sourcepub fn dequeue_rate(queue: Grc<Self>) -> impl Event<Item = f64> + Clone
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.
Sourcepub fn dequeue_extract_rate(queue: Grc<Self>) -> impl Event<Item = f64> + Clone
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.
Sourcepub fn wait_time(
queue: Grc<Self>,
) -> impl Event<Item = SamplingStats<f64>> + Clone
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.
Sourcepub fn wait_time_changed(
queue: Grc<Self>,
) -> impl Observable<Message = SamplingStats<f64>> + Clone
pub fn wait_time_changed( queue: Grc<Self>, ) -> impl Observable<Message = SamplingStats<f64>> + Clone
Notifies when the wait_time property changes.
Sourcepub fn wait_time_changed_(&self) -> impl Observable<Message = ()> + Clone
pub fn wait_time_changed_(&self) -> impl Observable<Message = ()> + Clone
Notifies when the wait_time property changes.
Sourcepub fn total_wait_time(
queue: Grc<Self>,
) -> impl Event<Item = SamplingStats<f64>> + Clone
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.
Sourcepub fn total_wait_time_changed(
queue: Grc<Self>,
) -> impl Observable<Message = SamplingStats<f64>> + Clone
pub fn total_wait_time_changed( queue: Grc<Self>, ) -> impl Observable<Message = SamplingStats<f64>> + Clone
Notifies when the total_wait_time property changes.
Sourcepub fn total_wait_time_changed_(&self) -> impl Observable<Message = ()> + Clone
pub fn total_wait_time_changed_(&self) -> impl Observable<Message = ()> + Clone
Notifies when the total_wait_time property changes.
Sourcepub fn enqueue_wait_time(
queue: Grc<Self>,
) -> impl Event<Item = SamplingStats<f64>> + Clone
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.
Sourcepub fn enqueue_wait_time_changed(
queue: Grc<Self>,
) -> impl Observable<Message = SamplingStats<f64>> + Clone
pub fn enqueue_wait_time_changed( queue: Grc<Self>, ) -> impl Observable<Message = SamplingStats<f64>> + Clone
Notifies when the enqueue_wait_time property changes.
Sourcepub fn enqueue_wait_time_changed_(
&self,
) -> impl Observable<Message = ()> + Clone
pub fn enqueue_wait_time_changed_( &self, ) -> impl Observable<Message = ()> + Clone
Notifies when the enqueue_wait_time property changes.
Sourcepub fn dequeue_wait_time(
queue: Grc<Self>,
) -> impl Event<Item = SamplingStats<f64>> + Clone
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.
Sourcepub fn dequeue_wait_time_changed(
queue: Grc<Self>,
) -> impl Observable<Message = SamplingStats<f64>> + Clone
pub fn dequeue_wait_time_changed( queue: Grc<Self>, ) -> impl Observable<Message = SamplingStats<f64>> + Clone
Notifies when the dequeue_wait_time property changes.
Sourcepub fn dequeue_wait_time_changed_(
&self,
) -> impl Observable<Message = ()> + Clone
pub fn dequeue_wait_time_changed_( &self, ) -> impl Observable<Message = ()> + Clone
Notifies when the dequeue_wait_time property changes.
Sourcepub fn rate(queue: Grc<Self>) -> impl Event<Item = f64> + Clone
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.
Sourcepub fn rate_changed(queue: Grc<Self>) -> impl Observable<Message = f64> + Clone
pub fn rate_changed(queue: Grc<Self>) -> impl Observable<Message = f64> + Clone
Notifies when the rate property changes.
Sourcepub fn rate_changed_(&self) -> impl Observable<Message = ()> + Clone
pub fn rate_changed_(&self) -> impl Observable<Message = ()> + Clone
Notifies when the rate property changes.
Sourcepub fn dequeue(queue: Grc<Self>) -> impl Process<Item = T> + Clone
pub fn dequeue(queue: Grc<Self>) -> impl Process<Item = T> + Clone
Dequeue by suspending the process if the queue is empty.
Sourcepub fn dequeue_with_output_priority(
queue: Grc<Self>,
po: SO::Priority,
) -> impl Process<Item = T> + Clone
pub fn dequeue_with_output_priority( queue: Grc<Self>, po: SO::Priority, ) -> impl Process<Item = T> + Clone
Dequeue with output prioerity by suspending the process if the queue is empty.
Sourcepub fn try_dequeue(queue: Grc<Self>) -> impl Event<Item = Option<T>> + Clone
pub fn try_dequeue(queue: Grc<Self>) -> impl Event<Item = Option<T>> + Clone
Try to dequeue immediately.
Sourcepub fn delete(queue: Grc<Self>, item: T) -> impl Event<Item = bool> + Clonewhere
T: PartialEq,
pub fn delete(queue: Grc<Self>, item: T) -> impl Event<Item = bool> + Clonewhere
T: PartialEq,
Remove the item from the queue and return a flag indicating whether the item was found and actually removed.
Sourcepub fn delete_(queue: Grc<Self>, item: T) -> impl Event<Item = ()> + Clonewhere
T: PartialEq,
pub fn delete_(queue: Grc<Self>, item: T) -> impl Event<Item = ()> + Clonewhere
T: PartialEq,
Remove the specified item from the queue.
Sourcepub fn delete_by<F>(
queue: Grc<Self>,
pred: F,
) -> impl Event<Item = Option<T>> + Clone
pub fn delete_by<F>( queue: Grc<Self>, pred: F, ) -> impl Event<Item = Option<T>> + Clone
Remove an item satisfying the specified predicate and return the item if found.
Sourcepub fn exists<F>(queue: Grc<Self>, pred: F) -> impl Event<Item = bool> + Clone
pub fn exists<F>(queue: Grc<Self>, pred: F) -> impl Event<Item = bool> + Clone
Test whether there is an item satisfying the specified predicate.
Sourcepub fn find<F>(
queue: Grc<Self>,
pred: F,
) -> impl Event<Item = Option<T>> + Clone
pub fn find<F>( queue: Grc<Self>, pred: F, ) -> impl Event<Item = Option<T>> + Clone
Find an item satisfying the specified predicate.
Sourcepub fn enqueue(queue: Grc<Self>, item: T) -> impl Process<Item = ()> + Clone
pub fn enqueue(queue: Grc<Self>, item: T) -> impl Process<Item = ()> + Clone
Enqueue the item by suspending the process if the queue is full.
Sourcepub fn enqueue_with_input_priority(
queue: Grc<Self>,
pi: SI::Priority,
item: T,
) -> impl Process<Item = ()> + Clone
pub fn enqueue_with_input_priority( queue: Grc<Self>, pi: SI::Priority, item: T, ) -> impl Process<Item = ()> + Clone
Enqueue the item with input priority by suspending the process if the queue is full.
Sourcepub fn enqueue_with_storing_priority(
queue: Grc<Self>,
pm: SM::Priority,
item: T,
) -> impl Process<Item = ()> + Clone
pub fn enqueue_with_storing_priority( queue: Grc<Self>, pm: SM::Priority, item: T, ) -> impl Process<Item = ()> + Clone
Enqueue the item with storing priority by suspending the process if the queue is full.
Sourcepub fn enqueue_with_input_and_storing_priorities(
queue: Grc<Self>,
pi: SI::Priority,
pm: SM::Priority,
item: T,
) -> impl Process<Item = ()> + Clone
pub fn enqueue_with_input_and_storing_priorities( queue: Grc<Self>, pi: SI::Priority, pm: SM::Priority, item: T, ) -> impl Process<Item = ()> + Clone
Enqueue the item with input and storing priorities by suspending the process if the queue is full.
Sourcepub fn try_enqueue(queue: Grc<Self>, item: T) -> impl Event<Item = bool> + Clone
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.
Sourcepub fn try_enqueue_with_storing_priority(
queue: Grc<Self>,
pm: SM::Priority,
item: T,
) -> impl Event<Item = bool> + Clone
pub fn try_enqueue_with_storing_priority( queue: Grc<Self>, pm: SM::Priority, item: T, ) -> impl Event<Item = bool> + Clone
Try to enqueue the item with storing priority. Return false
within Event computation if the queue is full.
Sourcepub fn enqueue_or_lose(
queue: Grc<Self>,
item: T,
) -> impl Event<Item = bool> + Clone
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.
Sourcepub fn enqueue_with_storing_priority_or_lose(
queue: Grc<Self>,
pm: SM::Priority,
item: T,
) -> impl Event<Item = bool> + Clone
pub fn enqueue_with_storing_priority_or_lose( queue: Grc<Self>, pm: SM::Priority, item: T, ) -> impl Event<Item = bool> + 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.
Sourcepub fn enqueue_or_lose_(
queue: Grc<Self>,
item: T,
) -> impl Event<Item = ()> + Clone
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.
Sourcepub fn enqueue_with_storing_priority_or_lose_(
queue: Grc<Self>,
pm: SM::Priority,
item: T,
) -> impl Event<Item = ()> + Clone
pub fn enqueue_with_storing_priority_or_lose_( queue: Grc<Self>, pm: SM::Priority, item: T, ) -> impl Event<Item = ()> + Clone
Try to enqueue the item with storing priority. If the queue is full then the item will be counted as lost.
Sourcepub fn enqueue_initiated(&self) -> impl Observable<Message = T> + Clone
pub fn enqueue_initiated(&self) -> impl Observable<Message = T> + Clone
Notifies when the enqueue operation is initiated.
Sourcepub fn enqueue_stored(&self) -> impl Observable<Message = T> + Clone
pub fn enqueue_stored(&self) -> impl Observable<Message = T> + Clone
Notifies when the item to be enqueued is stored.
Sourcepub fn enqueue_lost(&self) -> impl Observable<Message = T> + Clone
pub fn enqueue_lost(&self) -> impl Observable<Message = T> + Clone
Notifies when the item that would have to be enqueued is lost.
Sourcepub fn dequeue_requested(&self) -> impl Observable<Message = ()> + Clone
pub fn dequeue_requested(&self) -> impl Observable<Message = ()> + Clone
Notifies when the dequeue operation is requested for.
Sourcepub fn dequeue_extracted(&self) -> impl Observable<Message = T> + Clone
pub fn dequeue_extracted(&self) -> impl Observable<Message = T> + Clone
Notifies when the item is dequeued.
Sourcepub fn changed_(&self) -> impl Observable<Message = ()> + Clone
pub fn changed_(&self) -> impl Observable<Message = ()> + Clone
Notifies whenever any property changes.