diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-20 01:45:46 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-20 02:33:46 -0300 |
| commit | 3eb6c09bc97c2e60a17e1663108f4b22e3d1308c (patch) | |
| tree | be4f3e4b73d299abcefb1abb52f1e6e8f31ba1c1 /runtime/session.zig | |
| parent | 11f55f018a5eb0699d58627a4f2ea39c2b7f5e89 (diff) | |
| download | pardes-3eb6c09bc97c2e60a17e1663108f4b22e3d1308c.tar.gz pardes-3eb6c09bc97c2e60a17e1663108f4b22e3d1308c.zip | |
dev, runtime: a session's file watches once (file_watch.Watches, a working name), the session loop's beside its ptys and queue: the kernel's descriptor, the table (each pane's mark and the theme's slot), the reader that posts `files_changed` to the one queue (the Inbox) and the Host's three file calls (Watches.Calls fills both frontends' write_file, watch_file, watch_theme); the terminal's reader (an Io task posting to vaxis's queue, its files_changed message) and the window's (a thread with a stop pipe, polling a non-blocking descriptor) are deleted for one Io task on a blocking descriptor ended by its cancel, as the ptys' readers are; a Restore lets go of the loop's table, so the frontend call `watched` is gone (ten calls to nine); what a user sees: nothing (the queue keeps one change flag however many reads posted it; a reader that cannot start leaves the session running unwatched, as the terminal's did, where the window's start failed); tui core-test 857/1007 (150 skipped; +1, the device's test), shell-test 1047/1050, term 17/17, pane 183/184, kitty 45/45, behaviour-test and --replay 275/275, process-test 0 of 144 failed (ttytaken once in the run, passed on its retry), soaks --clients 5 and --bytes --clients 5 diverged 0, unequal 0, quiet checks 597/0 673/0 779/0 and 920/0 723/0 755/0, unlisted 0, corpus scene 22 of 22, no leak; gui unit-test 1643/1647 with only the perf check's BaselineHarnessMismatch; daemon.py plain, --far, --games, --window-clients, --upgrade both ways pass; the macOS library (Linux, aarch64-macos) and FreeBSD build (load 9-18)
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'runtime/session.zig')
| -rw-r--r-- | runtime/session.zig | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/runtime/session.zig b/runtime/session.zig index 3942aa83..6f8ab4a3 100644 --- a/runtime/session.zig +++ b/runtime/session.zig @@ -3,11 +3,12 @@ //! the session's allocators and workers, its core (an upgrade's, a dump's //! or a new one), the prompt files its shells start with, its 9P listener //! its replica clients (`Peers`), its queue (the workers' and readers' -//! posts, `Inbox`) and its ptys (`Ptys`): a step, its unit to the clients -//! and theirs taken in, an Upgrade or a Restore between steps; and the -//! order its parts end in. Its other devices (the files watched, the LSP's -//! and the pipes' and addons' jobs, the session's own input) are still its -//! frontend's (each `Shell`). What a frontend does is: +//! posts, `Inbox`), its ptys (`Ptys`) and the files it watches +//! (`file_watch.Watches`): a step, its unit to the clients and theirs +//! taken in, an Upgrade or a Restore between steps; and the order its +//! parts end in. Its other devices (the LSP's and the pipes' and addons' +//! jobs, the session's own input) are still its frontend's (each `Shell`). +//! What a frontend does is: //! //! - `options(o)`: before the core: what it gives the core it starts (a //! window's size, for a dump's layout). @@ -17,15 +18,14 @@ //! core's first effects (an upgraded terminal's panes its own again, //! whether anyone looks). //! - `close(l)`: its devices stopped, after the clients are let go and -//! before the ptys, the queue and the core go. -//! - `start(l)`: after the first effects, the ptys read: its input, its -//! readers, the -//! listener's wake, a detached session's first wait (`l.watch`). +//! before the watches, the ptys, the queue and the core go. +//! - `start(l)`: after the first effects, the ptys and the watches +//! read: its input, its readers, the listener's wake, a detached +//! session's first wait (`l.watch`). //! - `sent()`: after each step's unit went to the clients. //! - `upgradeAsked()`: an Upgrade asked in the step, done (it execs). //! - `note(n)`: what the daemon says (a terminal, an adopted shell, a //! client's connection), onto its queue. -//! - `watched()`: the files it watches (a Restore stops watching them). //! - `restoring(nc)`, `restored(l)`: a Restore's new core, before it //! replaces the old one (its devices let go, what it is told of the //! frontend) and after (its own view of it again). @@ -39,9 +39,6 @@ const daemon = @import("daemon.zig"); const upgrade = @import("upgrade.zig"); const ninep_io = @import("9p_io.zig"); -/// The files a frontend watches (host_io.restoreCore lets them go). -pub const Watched = struct { fd: c_int, table: *file_watch.Table }; - pub fn Loop(comptime Frontend: type) type { return struct { const L = @This(); @@ -58,6 +55,7 @@ pub fn Loop(comptime Frontend: type) type { /// to take in its wait. inbox: host_io.Inbox = undefined, ptys: Ptys = undefined, + watches: file_watch.Watches = undefined, fs: ?*ninep_io.Listener = null, peers: replica.Peers = .{}, host: pardes.Host = undefined, @@ -93,6 +91,8 @@ pub fn Loop(comptime Frontend: type) type { defer l.inbox.deinit(); l.ptys = .{ .queue = &l.inbox, .prompt_rcs = &l.prompt_rcs }; defer l.ptys.deinit(); + l.watches = .open(l.io, l.gpa, &l.inbox); + defer l.watches.deinit(); l.host = try fe.open(&l); defer fe.close(&l); @@ -107,6 +107,7 @@ pub fn Loop(comptime Frontend: type) type { l.effects(); } l.ptys.start(l.core); + l.watches.start(); try fe.start(&l); while (!l.core.quit) { @@ -154,8 +155,7 @@ pub fn Loop(comptime Frontend: type) type { /// let go (host_io.restoreCore); its shells and the frontend's /// devices with it. fn restore(l: *L, path: []const u8) void { - const w = l.fe.watched(); - const nc = host_io.restoreCore(l.gpa, l.core, path, &l.peers, w.fd, w.table) orelse return; + const nc = host_io.restoreCore(l.gpa, l.core, path, &l.peers, l.watches.fd, &l.watches.table) orelse return; l.fe.restoring(nc); l.ptys.stop(); nc.host = l.host; |
