|
trafilo 0.1.0
Streaming event-handler framework in C
|
Functions | |
| static long | timespec_diff_ms (struct timespec start, struct timespec end) |
| Helper to calculate difference in milliseconds between two timespecs. Returns long (end - start). | |
| void | sliding_window_init (sliding_window_t *w, long window_size_ms, long slide_ms) |
| Initialize a sliding window. | |
| void | sliding_window_destroy (sliding_window_t *w) |
| Graceful cleanup of a window. Frees all ts_node_t in the window, not the window itself. | |
| int | sliding_window_add (sliding_window_t *w, struct timespec event_ts) |
| Append the event timestamp as ts_node_t to tail. Evicts head while head->ts < (event_ts - window_size_ms). | |
| int | sliding_window_should_emit (const sliding_window_t *w, struct timespec now) |
| Checks if it's time to emit (slide_ms elapsed since last emit). | |
| void | sliding_window_mark_emitted (sliding_window_t *w, struct timespec now) |
| Called on emit, sets the last emit time. | |
| size_t | sliding_window_count (const sliding_window_t *w) |
| Get the count of events currently in the window. | |
| struct timespec | sliding_window_oldest (const sliding_window_t *w) |
| Get the timestamp of the oldest event in the window. | |
| struct timespec | sliding_window_newest (const sliding_window_t *w) |
| Get the timestamp of the newest event in the window. | |
| int sliding_window_add | ( | sliding_window_t * | w, |
| struct timespec | event_ts ) |
Append the event timestamp as ts_node_t to tail. Evicts head while head->ts < (event_ts - window_size_ms).
| w | Pointer to the window. |
| event_ts | Timestamp of the event. |
| size_t sliding_window_count | ( | const sliding_window_t * | w | ) |
Get the count of events currently in the window.
| w | Pointer to the window. |
| void sliding_window_destroy | ( | sliding_window_t * | w | ) |
Graceful cleanup of a window. Frees all ts_node_t in the window, not the window itself.
| w | Pointer to the window. |
| void sliding_window_init | ( | sliding_window_t * | w, |
| long | window_size_ms, | ||
| long | slide_ms ) |
Initialize a sliding window.
| w | Pointer to the window. |
| window_size_ms | Window span. |
| slide_ms | Sliding interval. |
| void sliding_window_mark_emitted | ( | sliding_window_t * | w, |
| struct timespec | now ) |
Called on emit, sets the last emit time.
| w | Pointer to the window. |
| now | Current timestamp. |
| struct timespec sliding_window_newest | ( | const sliding_window_t * | w | ) |
Get the timestamp of the newest event in the window.
| w | Pointer to the window. |
| struct timespec sliding_window_oldest | ( | const sliding_window_t * | w | ) |
Get the timestamp of the oldest event in the window.
| w | Pointer to the window. |
| int sliding_window_should_emit | ( | const sliding_window_t * | w, |
| struct timespec | now ) |
Checks if it's time to emit (slide_ms elapsed since last emit).
| w | Pointer to the window. |
| now | Current timestamp. |
|
static |
Helper to calculate difference in milliseconds between two timespecs. Returns long (end - start).