Crate ferris [−] [src]
A hierarchical timer wheel
There are 3 wheels in the hierarchy, of resolution 10ms, 1s, and 1m. The max timeout length is 1 hour. Any timer scheduled over 1 hour will expire in 1 hour.
There is no migration between wheels. A timer is assigned to a single wheel and is scheduled at the max resolution of the wheel. E.g. If a timer is scheduled for 1.3s it will be scheduled to fire 2 second ticks later. This is most useful for coarse grain timers and is more efficient computationally and uses less memory than being more precise. The wheels don't have to keep track of offsets for the next inner wheel so the timer can be rescheduled when the outer wheel slot expires. And it doesn't have to actually do the reschedule, saving cpu, and potentially extra allocations.
Structs
AllocWheel |
This wheel requires an allocation for each timer as it creates an Rc |
CopyWheel |
This wheel maintains a copy of the timer key in both the appropriate inner timer wheel slot and the global hashset. This does not require an allocation for each timer but may use more memory than an CopyWheel depending upon the size of the keys. When the expiry for a slot occurs, the global hashmap is checked for the expiring keys. If they are still there it means they are valid to expire, otherwise they have already been cancelled. |
Enums
Resolution |
A resolution for a wheel in the hierarchy |
Traits
Wheel |
Functions
wheel_sizes |
Determine the wheel size for each resolution. |