gitoria

components

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit519b56e9519b56e9styles.hl: Style in the language's form (nested like the View, one declaration per line, bare @media)mre519b56e9/plugins/time/Timer.hl

3.3 KB

  1. \* Timer.hl → class Timer — ONE clock event source, its lifetime, its events.
  2. `every(n)`, `after(n)` and `until(t)` all hand back one of these. The event
  3. loop wiring lives HERE so app code never sees it: the source is registered AT
  4. this instance, the internal fan-out re-emits `tick` at itself, and
  5. `on interval.tick()` in the app is an ordinary instance-scoped handler — the
  6. same shape hl:proc's Process has carried since 2026-08-17.
  7. let interval = every(360)
  8. on interval.tick(t) { … } \\ t = { count, at }
  9. interval.stop()
  10. ONE EVENT NAME FOR ALL THREE. `after(n)` IS `every(n)` that fires once and
  11. `until(t)` IS `after(t - now())`; one primitive, two conveniences. Naming the
  12. one-shot's event `finished` or `isUp` would mean swapping the constructor
  13. forces rewriting the handler, and this language's events are verbs of arrival
  14. — `line`, `exit`, `chunk`, `ready`, `saved`, `tick`. *\
  15. \* The interval this timer was created with, in seconds (raised to hl:time's
  16. floor if it was written below it — see server.hl). *\
  17. Number seconds = 0
  18. \* True for `every()`; false for the one-shots `after()` and `until()`. *\
  19. Boolean repeating = false
  20. \* False once a one-shot has fired or `stop()` was called. An `every` whose
  21. `running` is true keeps the program alive — that is the point of it. *\
  22. Boolean running = false
  23. \* How many ticks have been delivered. 1 on a one-shot's only tick. *\
  24. Number count = 0
  25. Number #id = 0
  26. Number #srcId = 0
  27. \* Arm the timer and register its source. Called by `every`/`after`/`until`;
  28. there is no reason to call it yourself. *\
  29. start(Number secs, Boolean repeat) {
  30. let armed = __native("time.timer", secs, repeat)
  31. #id = armed.id
  32. seconds = secs
  33. repeating = repeat
  34. running = true
  35. #srcId = __native("eventloop.register", armed.events, "__timerTick")
  36. // ONE TICK AT A TIME (ticket #159): a tick handler that waits (a fetch parks its fiber and the
  37. // loop runs the others) is not entered again by this clock; the next tick comes once it returned
  38. // (a LITERAL op, NativeCompile.hl `nativeCall` → hl_eventloop_serial: a computed one would make
  39. // every program importing hl:time, the compiler too, link dynamic — ticket #165)
  40. __native("eventloop.serial", #srcId)
  41. return this
  42. }
  43. on __timerTick(ev) {
  44. count = ev.count
  45. if (repeating == false) {
  46. // A SPENT ONE-SHOT RETIRES ITS SOURCE, BEFORE the tick is emitted.
  47. // Mission 249 found the same defect in hl:proc on 2026-08-29: a child
  48. // that had exited left its source registered, so the loop still held
  49. // something that would never speak again and NO hl:proc program could
  50. // ever end. An `after()` that does not retire hangs every program that
  51. // uses one, which is why the test for this asserts TERMINATION and not
  52. // output.
  53. running = false
  54. __native("eventloop.unregister", #srcId)
  55. __native("time.timer_stop", #id)
  56. }
  57. emit tick(ev)
  58. return null
  59. }
  60. \* Stop an interval (and end the program, if it was the only thing keeping it
  61. alive) — the counterpart of `server.kill()`. True when this call was the one
  62. that stopped it; false if it had already fired or been stopped. *\
  63. stop() {
  64. if (running == false) {
  65. return false
  66. }
  67. running = false
  68. // ORDER IS LOAD-BEARING: retire the source first, so the loop has dropped
  69. // this fd from its epoll set before the fd is closed.
  70. __native("eventloop.unregister", #srcId)
  71. __native("time.timer_stop", #id)
  72. return true
  73. }

Branches

Latest commits

  • 519b56e9styles.hl: Style in the language's form (nested like the View, one declaration per line, bare @media)mre
  • 29f63d01md-editor: Style in the language's form (nested like the View, one declaration per line, bare @media)mre
  • 869f49c7files-upload: Style in the language's form (nested like the View, one declaration per line, bare @media)mre
  • f60dab20month-view: Style in the language's form (nested like the View, one declaration per line, bare @media)mre
  • 5b3c349aRe-vendor to Hybriel set day35 (cb9e480d): plugins core and web sources, README vendoring notemre
  • 3449b117components: a startup error prints its message before exit 1 (hybriel#247)mre
  • 59704ce1Merge branch 'n5b-pipes'mre
  • 23b9164aMdEditor: a clipboard whose text is only the names or file:// paths of its files (a file manager copy) is about the files, as before; any other text wins (tickets#49); gate casesmre
  • b0f1ec28MdEditor: a clipboard with text always pastes the text, also when a picture is on it too (a spreadsheet or office app), files on or off; a picture alone still goes to the files; real Ctrl+V gate tests/md-paste-files.mjs (tickets#49)mre
  • ad4e929bMdEditor: pipe rows without a delimiter row are a table (first row = header, short rows padded, written back without an invented | --- | line) (notes#5)mre
  • 4bd11128MdEditor: the Table button's empty table is written as a real pipe table (empty cells), so it survives the source switch, a save and a reload (notes#7)mre
  • 7437e32bMdEditor draws its surface at once when claimed from server HTML: 1 ms mount animation, the first editor mounts all editors of the pagemre
  • 5de0264cRe-vendor onto Hybriel master acaceaf3 (set-day27b): binary, lib and plugins; exit 1 on a startup fault; .gitignore binmre
  • 79c77e7dMerge sb3-standby: components deploys through its standbymre
  • c5442043components: no jobs switch needed in the standbymre
  • 8d2fb24ccomponents: a standby container (port 45016, profile standby); deploy hands over through standby-swap.sh without a gapmre
  • c2834dd3Merge mr-fixes: media player state after a queue pick, Range handling, cover-less audio, accessibility labelsmre
  • 354fe3c6Media player: audio without a cover starts and shows its time (the mount tick sits on the seek bar, which every item has); the speed button names the current speed, the seek slider says its time in words; a gate page for the first render on cover-less audio and a fourth demo queue item without a covermre
  • ee4aee1eMedia player: a new queue item shows its own speed, mute, play state and time and starts when asked, also for two videos in a row; the media route reads suffix ranges and ignores range lists and garbage instead of answering 500; stronger gate checks (the 10 percent drag, the played bar, the queue tap)mre
  • 9a4f9b31Merge mp-player: media served from the committed filesmre