Skip to content

Add bounded timer waits and cancellation callbacks - #4

Merged
renerocksai merged 2 commits into
mainfrom
feat/typed-continuation-seams
Sep 6, 2026
Merged

Add bounded timer waits and cancellation callbacks#4
renerocksai merged 2 commits into
mainfrom
feat/typed-continuation-seams

Conversation

@renerocksai

@renerocksai renerocksai commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Return-and-resume handlers can now wait on timers without keeping worker threads occupied. Opt-in cancellation callbacks release retained application state after abandoned flushes and waits.

  • Add Context.wait(delay_ns), .timer, and opt-in .cancelled callbacks.
  • Retain request deadlines, executor ownership, and transport borrows through cancellation.
  • Drain earlier pipeline responses before a subsequent request waits.
  • Require local cleanup before .finish or .close; those actions never trigger an extra callback.
  • Keep timer storage bounded per slot, without new threads, kernel operations, or request-time allocation.

The timer uses a fresh monotonic timestamp. Existing polling can delay wakeups. This interface does not provide dynamic output leases. Application state and locals remain ineligible for output borrowing.

Exact candidate 6f6af03e828159455b91cece6ba468201651e1f6 passed native verification with Zig 0.16.0. Debug and ReleaseSafe each completed all 16 build steps.

Platform Test executions per mode Existing wire groups Continuation groups
Linux x64 109 passed, 2 platform skips 84 passed 9 passed
macOS ARM64 107 passed, 4 platform skips 84 passed 8 passed; unsupported three-owner topology skipped
Windows x64 122 passed, 4 platform skips 80 passed 9 passed

Linux/macOS native run and Windows native run passed. Windows also passed nine shard cases and the 30,000-response correctness smoke gate. Documentation and offline whitepaper checks passed locally.

Fixtures cover 32 waiters sharing one worker, depth-128 pipelines, partial sends, one-slot reuse, and shutdown. Deterministic tests cover terminal-result races, queued cancellation, stale clocks, and frozen batches. The first Windows attempt exposed an omitted socket-error class in the test retry; the final candidate includes that correction. No Zig source changed for that correction. No performance tests were run.

@renerocksai
renerocksai merged commit 165450e into main Sep 6, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant