Systems
vrealtime
Runs tasks by priority and deadline, in the same order every time.
Released v1.0.0 · 2026-09-28use "stdlib/realtime.ven"
A deterministic, priority and deadline ordered task scheduler, built entirely on Venutian's own concurrency primitives: spawn, await, share and protect. It orders work by priority and deadline rather than by arrival order, and is built from the language's own existing concurrency tools rather than a new scheduler underneath the language.
sched = scheduler_new()
print pending_count(sched)
Reference (9 functions)
API reference
scheduler_new()
Creates one new, independent priority/deadline scheduler.
sched = scheduler_new()
print pending_count(sched)schedule(sched, fn, priority)
Submits fn to sched at a given priority, unlabeled.
sched = scheduler_new()
schedule(sched, make() give "low", 1)
schedule(sched, make() give "high", 10)
results = run_all(sched)
print map_get(results[0], "result")schedule_labeled(sched, fn, priority, label)
Submits fn to sched at a given priority, tagged with label.
sched = scheduler_new()
schedule_labeled(sched, make() give 1, 1, "low")
schedule_labeled(sched, make() give 2, 10, "high")
results = run_all(sched)
print map_get(results[0], "label")schedule_before(sched, fn, deadline)
Submits fn to sched with an Earliest Deadline First deadline, unlabeled.
sched = scheduler_new()
schedule_before(sched, make() give "soon", 100)
schedule_before(sched, make() give "later", 200)
results = run_all(sched)
print map_get(results[0], "result")schedule_before_labeled(sched, fn, deadline, label)
Submits fn to sched with an EDF deadline, tagged with label.
sched = scheduler_new()
schedule_before_labeled(sched, make() give "a", 300, "far")
schedule_before_labeled(sched, make() give "b", 100, "near")
results = run_all(sched)
print map_get(results[0], "label")try_pop_next(sched)
Pops and returns the single most-urgent entry from sched, if any.
sched = scheduler_new()
print try_pop_next(sched)
schedule_labeled(sched, make() give 1, 5, "only")
popped = try_pop_next(sched)
print popped[0]
print map_get(popped[1], "label")pending_count(sched)
Gives back how many entries are currently queued in sched.
sched = scheduler_new()
schedule(sched, make() give 1, 1)
print pending_count(sched)run_all(sched)
Drains sched completely, sequentially, on the calling thread.
sched = scheduler_new()
schedule_labeled(sched, make() give 1, 1, "low")
schedule_labeled(sched, make() give 2, 10, "high")
results = run_all(sched)
print map_get(results[0], "label")
print map_get(results[1], "label")spawn_all(sched)
Drains sched concurrently, spawning each popped entry onto its own thread.
sched = scheduler_new()
schedule_labeled(sched, make() give 1, 1, "low")
schedule_labeled(sched, make() give 2, 10, "high")
launched = spawn_all(sched)
print map_get(launched[0], "label")
print await map_get(launched[0], "task")