Struct ferris::AllocWheel [] [src]

pub struct AllocWheel<T: Eq + Hash + Debug + Clone> { /* fields omitted */ }

This wheel requires an allocation for each timer as it creates an Rc for its key. This allows the key to be stored in a global hashset that can be used for O(1) cancel. A Weak<T> is stored in the wheel slot, so that if the timer is cancelled, the memory is de-allocatd. When the expiry for that slot comes around, an attempt to promote the Weak reference will return None and so it will be ignored when draining the wheel slot. If the timer expires before it is cancelled, the weak reference can be used to remove the Rc from the HashMap, as well as trigger the user timeout behavior.

The minimum duration of a timer is 1 ms. The maximum duration of a timer is 1 day.

Methods

impl<T: Eq + Hash + Debug + Clone> AllocWheel<T>
[src]

Create a set of hierarchical inner wheels

The wheel must be driven by calling expire at the maximum resolution. For example if the maximum resolution is 10ms, then expire must be called every 10ms.

The maximum value of the wheel is its minimum resolution times the number of slots in that resolution's wheel. For example if the maximum resolution is 1 second then the max timer that may be represented is 1 minute, since the second wheel always only contains 60 slots. If larger timer durations are desired, the user should add another, lower resolution. The absolute maximum timer duration is 1 day.

Trait Implementations

impl<T: Eq + Hash + Debug + Clone> Wheel<T> for AllocWheel<T>
[src]

Start a timer with the given duration.

Cancel a timer.

Return any expired timer keys