diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-20 00:03:29 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-20 00:03:29 -0300 |
| commit | 3a3601f984d25f1e03cee3ac47da7eeb2548e511 (patch) | |
| tree | 445331cb8ad346989c4e4f6a3ceff54411064e4a /core/Stream.zig | |
| parent | 8a1f65a2d374796b9b5559c4aab87c8d1e8f6e68 (diff) | |
| parent | 528530ed065b2059d16b08efd92103d1dbbccc31 (diff) | |
| download | pardes-3a3601f984d25f1e03cee3ac47da7eeb2548e511.tar.gz pardes-3a3601f984d25f1e03cee3ac47da7eeb2548e511.zip | |
integration: a far client's seven small faults on the renamed tree: pardes-far-faults (a refocus that no longer asks the session's host about a newer build; a drag in a kind's pane grown too short; a draw's token that no rollback takes back; a text's declarations dumped so a joined client's query reads what the session's does; a search that goes on at once on a far client; two tests of what cannot happen) and pardes-merge24, merged without a textual conflict; the coordinator's gate in the ledger (reorg/merge25)
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/Stream.zig')
| -rw-r--r-- | core/Stream.zig | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/core/Stream.zig b/core/Stream.zig index 74c8128a..5960d249 100644 --- a/core/Stream.zig +++ b/core/Stream.zig @@ -559,7 +559,7 @@ pub fn step(p: *Pardes) void { s.state = .searching; // A script's write (whose answer says whether it found anything) and a // host with no workers: done before this returns. - if (p.host.vtable.search != null and !p.fs.serving) p.emit(.{ .search = .{ .gen = s.gen } }) else runHere(p, s.gen); + if (p.host.vtable.search != null and !p.fs.serving) p.emit(.{ .search = .{ .gen = s.gen } }) else runHere(p, s.gen, false); } /// When the core next needs a tick for the stream: the end of the pause. @@ -576,12 +576,8 @@ pub fn start(io: std.Io, gpa: std.mem.Allocator, p: *Pardes, gen: u32, ctx: ?*an if (gen & paint_bit != 0) { for ([_]*?TextTask{ &s.paint, &s.rows_paint }) |slot| if (slot.*) |*t| if (t.job.gen == gen and t.future == null) { t.job.out = gpa; - t.future = io.concurrent(paintWork, .{ io, t.job, ctx, sink }) catch { - const job = t.job; - slot.* = null; - job.deinit(); - return; - }; + // No worker to be had: let go as runHere does, by an input. + t.future = io.concurrent(paintWork, .{ io, t.job, ctx, sink }) catch return runHere(p, gen, true); t.io = io; }; return; @@ -589,12 +585,9 @@ pub fn start(io: std.Io, gpa: std.mem.Allocator, p: *Pardes, gen: u32, ctx: ?*an // A parse's generation: its own task. if (s.parse) |*t| if (gen == s.parse_gen and t.job.gen == gen and t.future == null) { t.job.out = gpa; - t.future = io.concurrent(parseWork, .{ io, t.job, ctx, sink }) catch { - const job = t.job; - s.parse = null; - job.deinit(); - return; - }; + // No worker to be had: let go by an input, a parse that found none. + t.future = io.concurrent(parseWork, .{ io, t.job, ctx, sink }) catch + return p.update(.{ .search = .{ .gen = gen, .parsed = .{ .serial = t.job.serial, .revision = t.job.revision } } }); t.io = io; return; }; @@ -607,7 +600,7 @@ pub fn start(io: std.Io, gpa: std.mem.Allocator, p: *Pardes, gen: u32, ctx: ?*an const future = io.concurrent(work, .{ io, job, ctx, sink }) catch { // No worker to be had: it runs here, on the loop. job.deinit(); - return runHere(p, gen); + return runHere(p, gen, true); }; s.task = .{ .job = job, .future = future, .io = io }; } @@ -625,13 +618,18 @@ fn makeJob(gpa: std.mem.Allocator, s: *const Stream) !*Job { /// A host with no workers (a test's, the fallback when none can be had): /// the whole search on the loop, the turn out for it, its batches taken in -/// as a worker's would be. Its cap is a hard stop. -pub fn runHere(p: *Pardes, gen: u32) void { +/// as a worker's would be. Its cap is a hard stop. `in_call`: run in the +/// host's `search` entry, where what it wrote into the core would be in no +/// record: each batch handed in as a worker's is, an input the tape records +/// and every replica takes. +pub fn runHere(p: *Pardes, gen: u32, comptime in_call: bool) void { // A paint with no worker to run it (a shell not threaded yet): let go, - // never left to hold its slot; the rows or the view ask again. + // never left to hold its slot; the rows or the view ask again. In a + // host's call, by an input: a worker's answer of nothing. if (gen & paint_bit != 0) { const s = &p.stream; for ([_]*?TextTask{ &s.paint, &s.rows_paint }) |slot| if (slot.*) |t| if (t.job.gen == gen and t.future == null) { + if (in_call) return p.update(.{ .search = .{ .gen = gen, .end = .done, .painted = .{ .serial = t.job.serial, .revision = t.job.revision, .start = t.job.start } } }); slot.* = null; t.job.deinit(); }; @@ -655,7 +653,7 @@ pub fn runHere(p: *Pardes, gen: u32) void { const batches = p.tape.site(.search, p.gpa, searchHere, .{ p.gpa, job }); defer p.gpa.free(batches); for (batches) |*b| { - receive(p, b); + if (in_call) p.update(.{ .search = b.* }) else receive(p, b); b.deinit(p.gpa); } } |
