Skip to content

v2.0.3 – Nested Coroutine Execution Fix

Choose a tag to compare

@g2px1 g2px1 released this 16 Oct 11:40
· 191 commits to main since this release

Release description:
This release introduces a critical fix enabling proper execution of nested coroutines (co_await task1() inside another co_await task2()), which previously caused suspended tasks not to resume or terminate incorrectly.

🧩 Core Changes

  • Fixed coroutine chaining logic in Awaitable and AwaitableFrame:
    • Correctly links parent and child coroutine handles (prev_ / next_).
    • Ensures child coroutines are properly scheduled only when not I/O-bound (AwaitableFrame<T> vs. AwaitableIOFrame<T>).
    • Prevents unwanted automatic resumption of I/O coroutines that must await epoll triggers.
  • Removed redundant resume() calls in await_resume() for void tasks to avoid unintended re-entry.
  • Added type traits to distinguish normal coroutine frames from I/O frames at compile time.

⚙️ Impact

  • Nested coroutine flows (e.g., co_await accept(); co_await some_task();) now execute in sequence as expected.
  • I/O coroutines (async_read, async_write, etc.) remain event-driven and suspended until triggered by epoll.
  • Eliminates potential infinite loops and early task execution in multi-await chains.

✅ Recommended Action

Update to this version if your code involves layered coroutine awaits, especially around asynchronous socket operations or custom Awaitable tasks.