Repository navigation
Add future protocol to Timeout for use with select() - #233
Conversation
Enables Timeout to be used directly in select() calls, allowing timeouts to race against other async operations like channel receives.
📝 WalkthroughWalkthroughAdds select()-compatible async timeout support to the Timeout type: introduces Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/time.zig`:
- Around line 371-376: In Timeout.asyncCancelWait, explicitly null out the wait
node pointer before calling loop.clearTimer to prevent a previously queued
callback from seeing a stale ctx.wait_node; update the function to set
ctx.wait_node = null (or equivalent) prior to calling
loop.clearTimer(&ctx.timer) so the callback's guard if (ctx.wait_node) |node|
cannot observe a pointer to a destroyed/reused wait node and cancellation
semantics are explicit.
Prevents a queued callback from waking a stale/reused wait node.
Summary
asyncWait,asyncCancelWait,getResult) to theTimeouttypeTimeoutto be used directly inselect()calls for timeout racesTest plan
./check.sh --filter "Timeout future"passes./check.sh --fullpasses (320/320 tests)