pub struct KeyedHashedWheelTimer<T, K, F>{ /* private fields */ }Expand description
Keyed wrapper over HashedWheelTimer.
A dedup key is produced by dedup_key_fn.
Scheduling/updating an event with an existing key replaces the previous one.
Implementations§
Source§impl<T, K, F> KeyedHashedWheelTimer<T, K, F>
impl<T, K, F> KeyedHashedWheelTimer<T, K, F>
Sourcepub fn count_in_bucket(
&self,
bucket_index: usize,
) -> Result<usize, TimeWheelError>
pub fn count_in_bucket( &self, bucket_index: usize, ) -> Result<usize, TimeWheelError>
Returns number of events in bucket by index.
Sourcepub fn is_empty_bucket(
&self,
bucket_index: usize,
) -> Result<bool, TimeWheelError>
pub fn is_empty_bucket( &self, bucket_index: usize, ) -> Result<bool, TimeWheelError>
Returns true when bucket contains no events.
Sourcepub fn has_events_in_current_tick(&self) -> bool
pub fn has_events_in_current_tick(&self) -> bool
Returns true if current tick still has events to pop.
Sourcepub fn curr_bucket(&self) -> usize
pub fn curr_bucket(&self) -> usize
Returns current bucket index.
Sourcepub fn curr_delta_tick(&self) -> u64
pub fn curr_delta_tick(&self) -> u64
Returns current wave (delta_tick) in the current tick.
Sourcepub fn curr_seq_id(&self) -> EventId
pub fn curr_seq_id(&self) -> EventId
Returns latest assigned sequence ID.
Sourcepub fn contains_by_id(&self, id: EventId) -> bool
pub fn contains_by_id(&self, id: EventId) -> bool
Returns true if event with ID exists.
Sourcepub fn contains_by_key(&self, key: &K) -> bool
pub fn contains_by_key(&self, key: &K) -> bool
Returns true if key exists.
Sourcepub fn get_by_key(&self, key: &K) -> Option<&Event<T>>
pub fn get_by_key(&self, key: &K) -> Option<&Event<T>>
Returns event by key.
Sourcepub fn schedule(&mut self, on_tick: u64, data: T) -> KeyedScheduleResult
pub fn schedule(&mut self, on_tick: u64, data: T) -> KeyedScheduleResult
Schedules an event.
If key already exists, previous event is replaced.
Sourcepub fn remove(&mut self, id: EventId) -> Option<Event<T>>
pub fn remove(&mut self, id: EventId) -> Option<Event<T>>
Removes event by ID and updates key index.
Sourcepub fn remove_by_key(&mut self, key: &K) -> Option<Event<T>>
pub fn remove_by_key(&mut self, key: &K) -> Option<Event<T>>
Removes event by dedup key.
Sourcepub fn update(
&mut self,
id: EventId,
on_tick: u64,
data: T,
) -> Option<KeyedUpdateResult>
pub fn update( &mut self, id: EventId, on_tick: u64, data: T, ) -> Option<KeyedUpdateResult>
Updates event by ID and applies key replacement semantics.
Sourcepub fn update_by_key(
&mut self,
key: &K,
on_tick: u64,
data: T,
) -> Option<KeyedUpdateResult>
pub fn update_by_key( &mut self, key: &K, on_tick: u64, data: T, ) -> Option<KeyedUpdateResult>
Updates event by key.
Sourcepub fn reschedule(
&mut self,
id: EventId,
on_tick: u64,
) -> Option<KeyedUpdateResult>
pub fn reschedule( &mut self, id: EventId, on_tick: u64, ) -> Option<KeyedUpdateResult>
Reschedules event by ID preserving payload and key.
Sourcepub fn reschedule_by_key(
&mut self,
key: &K,
on_tick: u64,
) -> Option<KeyedUpdateResult>
pub fn reschedule_by_key( &mut self, key: &K, on_tick: u64, ) -> Option<KeyedUpdateResult>
Reschedules event by key.
Sourcepub fn pop_events(&mut self) -> Vec<Event<T>>
pub fn pop_events(&mut self) -> Vec<Event<T>>
Pops one current-tick wave and keeps key index in sync.