tracker
All repositories: gitoria
3.3 KB
\* Timer.hl → class Timer — ONE clock event source, its lifetime, its events.`every(n)`, `after(n)` and `until(t)` all hand back one of these. The eventloop wiring lives HERE so app code never sees it: the source is registered ATthis instance, the internal fan-out re-emits `tick` at itself, and`on interval.tick()` in the app is an ordinary instance-scoped handler — thesame shape hl:proc's Process has carried since 2026-08-17.let interval = every(360)on interval.tick(t) { … } \\ t = { count, at }interval.stop()ONE EVENT NAME FOR ALL THREE. `after(n)` IS `every(n)` that fires once and`until(t)` IS `after(t - now())`; one primitive, two conveniences. Naming theone-shot's event `finished` or `isUp` would mean swapping the constructorforces rewriting the handler, and this language's events are verbs of arrival— `line`, `exit`, `chunk`, `ready`, `saved`, `tick`. *\\* The interval this timer was created with, in seconds (raised to hl:time'sfloor if it was written below it — see server.hl). *\Number seconds = 0\* True for `every()`; false for the one-shots `after()` and `until()`. *\Boolean repeating = false\* False once a one-shot has fired or `stop()` was called. An `every` whose`running` is true keeps the program alive — that is the point of it. *\Boolean running = false\* How many ticks have been delivered. 1 on a one-shot's only tick. *\Number count = 0Number #id = 0Number #srcId = 0\* Arm the timer and register its source. Called by `every`/`after`/`until`;there is no reason to call it yourself. *\start(Number secs, Boolean repeat) {let armed = __native("time.timer", secs, repeat)#id = armed.idseconds = secsrepeating = repeatrunning = true#srcId = __native("eventloop.register", armed.events, "__timerTick")// ONE TICK AT A TIME (ticket #159): a tick handler that waits (a fetch parks its fiber and the// loop runs the others) is not entered again by this clock; the next tick comes once it returned// (a LITERAL op, NativeCompile.hl `nativeCall` → hl_eventloop_serial: a computed one would make// every program importing hl:time, the compiler too, link dynamic — ticket #165)__native("eventloop.serial", #srcId)return this}on __timerTick(ev) {count = ev.countif (repeating == false) {// A SPENT ONE-SHOT RETIRES ITS SOURCE, BEFORE the tick is emitted.// Mission 249 found the same defect in hl:proc on 2026-08-29: a child// that had exited left its source registered, so the loop still held// something that would never speak again and NO hl:proc program could// ever end. An `after()` that does not retire hangs every program that// uses one, which is why the test for this asserts TERMINATION and not// output.running = false__native("eventloop.unregister", #srcId)__native("time.timer_stop", #id)}emit tick(ev)return null}\* Stop an interval (and end the program, if it was the only thing keeping italive) — the counterpart of `server.kill()`. True when this call was the onethat stopped it; false if it had already fired or been stopped. *\stop() {if (running == false) {return false}running = false// ORDER IS LOAD-BEARING: retire the source first, so the loop has dropped// this fd from its epoll set before the fd is closed.__native("eventloop.unregister", #srcId)__native("time.timer_stop", #id)return true}
Branches
Latest commits
- 89606a5cHM65 briefmre
- 096ce0d4log: DP69 live on day48mre
- b3d8a80bDP69 brief, RV48 mergedmre
- ce6d7d32Merge rv48: Hybriel day48mre
- 3da2ea86RV48: report day48 cold starts, gates and cleanupmre
- 8d9ecdfeRV48: re-vendor Hybriel set day48 (source b6a8f429, bin 660a9524)mre
- 4a802ae7status: RV48 runningmre
- 0a5412b6RV48 brief, day48 outmre
- 56665efelog: CB69 mergedmre
- 05448a98Merge cb69-imports: appTitle in a dependency-free topicmre
- e55b379dKeep shared app title independent of the route import graphmre
- 9a99659blog: hybriel#334, batch waits for day48mre
- 85fa6c9blog: CB68 result, CB69 startedmre
- 2f07c1b7log: DP68 boot gate failed, CB68mre
- 9652782dlog: HM59 merged, DP68 startedmre
- 29867a75Merge hm59-logic: tracker#59 page logic moved to libmre
- f7bfe90bMove remaining page builders into their topicsmre
- 7c3991f9log: day46 from Antonmre
- ec54fc35Move show page logic into the shows topicmre
- c1a8d074log: correct timesmre