pub struct TimerDequeConsumer<R, MODE>{ /* private fields */ }Expand description
This type of the queue consumes the instance for which the timer is set. The item must be Send and Clone, std::sync::Arc. This is convinient when it is required to store the instance in the timer and retrive it when the timeout happens. This method allows to avoid for lookups in the lists and working directly with the stored items.
§Generics
R - an instance which should be stored on the timer dequeue. The instance
must implement PartialEq, Eq, fmt::Debug, fmt::Display, Send.
MODE - a OrderedTimerDequeMode which defines the deque behaviour. There are
two types of the operation:
-
[OrderdTimerDequeOnce] - after timeout the element is removed from the queue.
-
[OrderdTimerDequePeriodic] - after timeout the element timeout is extended until the item is not removed from the queue manually.
§Example
let mut time_list =
OrderedTimerDeque
::<DequeOnce, TimerDequeConsumer<u64, _>>
::new("test_label1".into(), 4, false, true)
.unwrap();or
let mut time_list =
OrderedTimerDeque
::<DequePeriodic, TimerDequeConsumer<u64, _>>
::new("test_label1".into(), 4, false, true)
.unwrap();Trait Implementations§
Source§impl<R, MODE> Debug for TimerDequeConsumer<R, MODE>
impl<R, MODE> Debug for TimerDequeConsumer<R, MODE>
Source§impl<R, MODE> Display for TimerDequeConsumer<R, MODE>
impl<R, MODE> Display for TimerDequeConsumer<R, MODE>
Source§impl<R, MODE> Ord for TimerDequeConsumer<R, MODE>
impl<R, MODE> Ord for TimerDequeConsumer<R, MODE>
Source§impl<MODE, R> OrderedTimerDequeHandle<MODE> for TimerDequeConsumer<R, MODE>
impl<MODE, R> OrderedTimerDequeHandle<MODE> for TimerDequeConsumer<R, MODE>
Source§type HandleRes = Vec<<TimerDequeConsumer<R, MODE> as OrderedTimerDequeHandle<MODE>>::TimerId>
type HandleRes = Vec<<TimerDequeConsumer<R, MODE> as OrderedTimerDequeHandle<MODE>>::TimerId>
Source§fn handle(
self,
timer_self: &mut OrderTimerDeque<MODE, Self>,
timer_ids: &mut Self::HandleRes,
) -> TimerResult<()>
fn handle( self, timer_self: &mut OrderTimerDeque<MODE, Self>, timer_ids: &mut Self::HandleRes, ) -> TimerResult<()>
collection and reschedule the item if it is repeated.Source§fn is_same(&self, other: &Self::TimerId) -> bool
fn is_same(&self, other: &Self::TimerId) -> bool
other instances
OrderedTimerDequeHandle::TimerId. But, the PartialEq<Self::TimerId> is
implemented, so the == can be used to compare.Source§fn postpone(&mut self, postp_time: RelativeTime) -> TimerResult<()>
fn postpone(&mut self, postp_time: RelativeTime) -> TimerResult<()>
postp_time is a RelativeTime
i.e inroduces the offset.Source§fn resched(&mut self, time: MODE) -> TimerResult<()>
fn resched(&mut self, time: MODE) -> TimerResult<()>
postpone as the
instance is assagned with a new time. The MODE cannot be changed, only time.