Sliding-window threshold scheduler
Wake on the third result.
Give KthWake an ordered stream of tool completions. It tells your event loop when a rule turns on and when it will turn off if no more results arrive.
Tool completion timeline
Rule #0- Window count
- Threshold met
- Clears if idle
Callback log
| Time (ms) | State | Trigger |
|---|
No callbacks through this tick.
Read callback log as JSONL
Drive the C++ index
Pass each timestamp’s arrivals together. Use the next expiry to drive the clock during idle periods. At a shared timestamp, a single step applies expirations and arrivals before reporting changes.
index.step(t, arrivals, callback);
auto deadline = index.next_expiry();Use KthWake in your event loop
Put one index after an ordered event stream. Pass the arrival count to step, dispatch the changed rule IDs, and arm one timer for the next idle deadline.
37.1 ms for 330,890 transitions
On a held-out Azure trace with 4,096 modeled individual-rate policies, the fastest tested alternative took 75.0 ms. A dedicated heap won the other two Azure timer workloads. Inspect all results.
Run the example
In the extracted source directory, run the bundled trace through the native CLI.
make example