#include <cq.h>
A callout queue is really a sorted linked list of events that are to happen in the near future, most recent coming first.
Naturally, the insertion/deletion of items has to be relatively efficient. We don't want to go through all the items in the list to find the proper position for insertion.
To do that, we maintain a parallel hash list of all the events, each event being inserted in the bucket i, where i is computed by abs_time size, abs_time being the absolute time where the event is to be triggered and size being the size of the hash list. All the items under the bucket list are further sorted by increasing trigger time.
To be completely generic, the callout queue "absolute time" is a mere unsigned long value. It can represent an amount of ms, or an amount of yet-to-come messages, or whatever. We don't care, and we don't want to care. The notion of "current time" is simply given by calling cq_clock() at regular intervals and giving it the "elasped time" since the last call.
Data Fields | |
chash * | cq_hash |
Array of buckets for hash list. | |
time_t | cq_time |
"current time" | |
gint | cq_ticks |
Number of cq_clock() calls processed. | |
gint | cq_items |
Amount of recorded events. | |
gint | cq_last_bucket |
Last bucket slot we were at. | |
chash * | cq_current |
Current bucket scanned in cq_clock(). |
|
Current bucket scanned in cq_clock().
|
|
Array of buckets for hash list.
|
|
Amount of recorded events.
|
|
Last bucket slot we were at.
|
|
Number of cq_clock() calls processed.
|
|
"current time"
|