https://gitlab.synchro.net/main/sbbs/-/commit/6d6869c23e820d62f42fff6d
Modified Files:
src/syncterm/scripts/syncterm.wren src/syncterm/term.c wren_bind.c wren_host.c wren_host.h wren_host_internal.h
Log Message:
SyncTERM: useful wren-cli module pieces — Platform + Timer
Two small classes lifted in spirit from wren-cli, adapted to our
fiber-arg / result-queue model rather than wren-cli's libuv +
Fiber.transfer + Scheduler.await_ shape.
Platform.name returns the uname(2) sysname on POSIX (e.g. "FreeBSD",
"Linux", "Darwin"), "Windows" on Windows, "Unknown" elsewhere. Win32
checked first so POSIX-overlay environments (Cygwin, MSYS) report
the native OS rather than uname's emulated reply. No isPosix or
shell-exec / process surface — scripts on this host don't need it.
Timer.trigger(fiber, ms) registers a one-shot resumption: pushes a
TimerElapsed onto the result queue once xp_timer() reaches the
absolute due-time, then the standard drainer resumes the fiber.
Multi-fire / event-loop dispatch by type works straight out of the
existing pattern:
Timer.trigger(Fiber.current, 100)
SFTP.stat(Fiber.current, "/foo")
while (true) {
var x = Fiber.yield()
if (x is TimerElapsed) { spinner.tick(); Timer.trigger(Fiber.current, 100) }
if (x is SFTPStat) { ... break }
if (x is SFTPError) { ... break }
}
For recurring fire-and-forget callbacks (no fiber resume), use
Hook.every(ms, fn) — different pattern, both useful.
Implementation: bounded array of (fiber, due_s) on wren_host_state.pending_timers, swept once per doterm() iteration
just before wren_result_drain. Past-due entries push TimerElapsed
to the result queue with NULL data; the deliver fn builds a
TimerElapsed foreign on demand. Cap is 32; overflow throws on
Timer.trigger so a runaway script fails loudly rather than silently
dropping registrations.
Skipped: wren-cli's Scheduler (redundant with our doterm + result
queue), io (async File/Directory; ours is intentionally synchronous
on the owner thread), Process / shell-exec, Stdin/Stdout/Stderr
(SyncTERM scripts don't have a CLI).
Co-Authored-By: Claude Opus 4.7 (1M context) <
noreply@anthropic.com>
---
■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net