https://gitlab.synchro.net/main/sbbs/-/commit/feab4f3a1cac2087b0260c95
Modified Files:
src/syncterm/Wren.adoc src/syncterm/scripts/auto/connected/console.wren src/syncterm/scripts/syncterm.wren wrentest.wren src/syncterm/term.c wren_bind.c wren_host.c wren_host.h wren_host_internal.h
Log Message:
SyncTERM: Wren result-queue framework + CTerm.suspended
Generic completion queue: callable C-side request data + fiber
handle + deliver/free callbacks travel through one mutex-protected
FIFO, drained at the top of each doterm() iteration. The drainer
walks each entry, skips fibers where Fiber.isDone (cached primitive
handle), builds the Wren foreign right before wrenCall, and
releases the handle + frees the data after. Workers can push from
any thread; delivery is owner-thread only.
Input.nextEvent now flows through the queue: dispatch_key/dispatch_mouse
push an input_result carrying the raw key code or mouse_event and
transfer the parked fiber handle. One-iteration latency on
delivery, but the wrenCall is no longer fired mid-foreign-stack.
Replaces the implicit "parking on Input.nextEvent claims the
screen" behavior with an explicit CTerm.suspended Bool. Backed
by a doterm() local; while true, the wire pump halts and bytes
pile up in the conn buffer until the TCP window fills and the
remote sees backpressure.
When the suspend flag transitions back to false, doterm() credits
the byte pump with all the bytes that would have drained at the
emulated rate during the suspended window. Those bytes burst past
the speed gate one per pump iteration until the credit runs out;
the visible output catches up to where it would have been with no
suspend. No-op when speed emulation is disabled.
Adds T06 to wrentest.wren that exercises the queue end-to-end:
parks a fiber on Input.nextEvent, ungets a sentinel key, sets +
clears CTerm.suspended around the resume, and verifies the fiber
captured the right KeyEvent. Also flips console.wren's launcher
hook to the filtered Hook.onKey(Key.wrenConsole) form.
Co-Authored-By: Claude Opus 4.7 (1M context) <
noreply@anthropic.com>
--- SBBSecho 3.37-Linux
* Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)