feat(async): track current running coroutine for graph export#80
feat(async): track current running coroutine for graph export#8016bit-ykiko wants to merge 2 commits intomainfrom
Conversation
…d edge cases Add 18 new test cases for function/function_ref: - Destructor tracking: verify no double-free or leak for SBO and heap storage across construct, move-construct, move-assign, and move chains - Cross-storage move assignment: SBO↔heap, fnptr↔SBO transitions with leak detection via TrackedCallable/LargeTrackedCallable - Self-move assignment: SBO and heap paths - function_ref: mutable lambda, reassign, bind_ref mutation visibility - Complex types: string return, multiple arguments, bind const mem_fn Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ph export Add a thread-local async_node* that always points to the coroutine currently executing on this thread. This allows calling async_node::current() or async_node::dump_current_dot() from anywhere inside a coroutine body to export the async graph on demand. Tracking points: - initial_tracking_suspend sets the node on first coroutine entry - async_node::resume() and resume_and_drain() save/restore around resumes - handle_subtask_result(), deliver_deferred(), propagate_fail() set the node before returning a handle for symmetric transfer Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR introduces thread-local tracking of the currently executing async_node across the coroutine runtime. It adds public APIs ( Changes
Sequence DiagramsequenceDiagram
participant Caller
participant TaskCoro as Task<br/>Coroutine
participant AsyncNode as async_node
participant ThreadLocal as Thread-Local<br/>Storage
Caller->>TaskCoro: co_await task
TaskCoro->>TaskCoro: initial_suspend()
TaskCoro->>ThreadLocal: set_current_node(this_node)
ThreadLocal-->>TaskCoro: ✓
TaskCoro-->>Caller: suspend, return handle
Caller->>AsyncNode: resume()
AsyncNode->>ThreadLocal: save prior current_node
ThreadLocal-->>AsyncNode: prior_node
AsyncNode->>TaskCoro: handle().resume()
TaskCoro->>TaskCoro: coroutine body executes
TaskCoro-->>AsyncNode: returns
AsyncNode->>ThreadLocal: restore prior_node
ThreadLocal-->>AsyncNode: ✓
AsyncNode-->>Caller: ✓
Note over TaskCoro,ThreadLocal: Exception path:<br/>propagate_fail() also<br/>sets current_node before<br/>resuming parent
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Summary
thread_local async_node*that tracks which coroutine is currently executing on each threadasync_node::current()andasync_node::dump_current_dot()public API so user code inside any coroutine can export the async graph on demandinitial_tracking_suspend(first entry), save/restore inresume()/resume_and_drain()(entry points), and direct assignment inhandle_subtask_result()/deliver_deferred()/propagate_fail()(symmetric transfer)Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
async_node::current()to retrieve the active coroutine node andasync_node::dump_current_dot()for state visualization.Tests