ReviewOS

also looking at this

home-lang/home

fix(async): preserve cancellation and add revision-aware job gate

#914
Merged chris wants to merge feat/camera-jobs into main
6 files +217 -20
8 days ago

An in-flight Task.poll could replace Cancelled with Completed or Pending, and cancel() could overwrite an already completed result. JoinHandle.await also spun indefinitely for Failed. Guard these transitions with terminal-preserving atomic CAS and return TaskFailed immediately. Cancellation still requires the polling owner to quiesce before task destruction.

Add a small allocation-free CompletionGate for revisioned event jobs: ignore stale events and terminal results before the active phase, and preserve success/failure/cancel/stop once terminal. zig-utils/zig-camera vendors this module for autofocus scan gating under its session mutex.

Validation: the complete 41-test async root suite passes locally in Debug and ReleaseSafe with Home's Zig 0.17 development toolchain (with threading_futex supplied). Fourteen task/future/state tests and two gate tests also pass with Zig 0.15.2. Regression cases reproduce cancellation inside both Ready and Pending polls, late cancellation, failed joins, stale revisions and terminal immutability. Add focused Linux x86/ARM CI.

6 changed files on the files tab, with 0 review threads.

Sign in to comment on this pull request.