sched
Simple Task Scheduler (Min-Heap)
Functions
| Function | Description |
|---|---|
sched_new | Create a new scheduler. |
_sched_swap | Internal: swap two entries in the heap. |
_sched_sift_up | Internal: sift up from index i. |
_sched_sift_down | Internal: sift down from index i, with count elements. |
sched_enter | Add a task to the scheduler. |
sched_cancel | Cancel a task by id. Returns 1 if found and removed. |
sched_next | Return id of the next (earliest) task, or -1 if empty. |
sched_next_time | Return time of the next (earliest) task. |
_sched_pop | Internal: remove the root element from the heap. |
sched_run | Run the next task if its time <= now. Returns task id or -1. |
sched_empty | Return 1 if the scheduler has no tasks. |
sched_count | Return the number of tasks. |
Details
sched_new
fn sched_new() -> &i64Create a new scheduler.
_sched_swap
fn _sched_swap(times: &i64, ids: &i64, a: i64, b: i64) -> i64Internal: swap two entries in the heap.
_sched_sift_up
fn _sched_sift_up(times: &i64, ids: &i64, i: i64) -> i64Internal: sift up from index i.
_sched_sift_down
fn _sched_sift_down(times: &i64, ids: &i64, i: i64, count: i64) -> i64Internal: sift down from index i, with count elements.
sched_enter
fn sched_enter(h: &i64, time: i64, id: i64) -> i64Add a task to the scheduler.
sched_cancel
fn sched_cancel(h: &i64, id: i64) -> i64Cancel a task by id. Returns 1 if found and removed.
sched_next
fn sched_next(h: &i64) -> i64Return id of the next (earliest) task, or -1 if empty.
sched_next_time
fn sched_next_time(h: &i64) -> i64Return time of the next (earliest) task.
_sched_pop
fn _sched_pop(h: &i64) -> i64Internal: remove the root element from the heap.
sched_run
fn sched_run(h: &i64, now: i64) -> i64Run the next task if its time <= now. Returns task id or -1.
sched_empty
fn sched_empty(h: &i64) -> i64Return 1 if the scheduler has no tasks.
sched_count
fn sched_count(h: &i64) -> i64Return the number of tasks.