Index of articles exploring C++ coroutines

What would it mean to create your own coroutine framework?

This series of articles/presentations is reviving an attempt to explore C++ coroutines that I worked on and off from 2023 onwards. It is a learning journey that covers interesting, but less common parts of C++.

Ivan: “This is not the C++ I’m used to see”

There are multiple goals. There is the indirect goal of generally learning about concurrency, about C++, but also specifically answering the question “what would it take to write a library that can do concurrency in C++, potentially involving coroutines”?

WORK IN PROGRESS

Presentations

Bibliography

TODO - topics to cover

  • More in threading model
    • embedded concurrency
      • detached mode
      • queue in hardware: interrupt priorities
    • GPU
      • NVIDIA motivation e.g.
        • use local GPU plus remote GPUs
        • use GPU to accelerate CPU work
    • executor/scheduler
    • granularity
  • What’s wrong with
    • std::async
    • std::future and std::promise
  • Cancellation
    • nature of cancellation
    • cooperative
      • poll
      • stop callback
    • asynchronous
      • best effort, e.g. might not cancel immediately or might still complete
    • what if cancel is slow: the server/detection pattern
    • hiding cancellation from function signature (e.g. see co_await get_cancellation_token()
  • Trampoline
  • Timers
  • context passing (adv/disadv):
    • explicit as an argument
    • buried
  • The issue of dual language:
    • e.g. implementing vs. using (as seen in boost::asio)
  • Threading synchronization in await_suspend
    • none (no cancellation)
    • mutex
    • atomic bool
  • C++ coroutine weak points
    • weak allocation control: have allocator, but allocation size is runtime info
      • no option to allocate on stack e.g. for a know type can control allocation on stack or heap (std::unique_ptr)
    • resume and destroy mechanisms are indirect calls: call a function that fetches a function pointer that makes a switch
    • a large vocabulary of terms: learning curve obstacle
  • senders receivers
    • compare example with read size then data (senders vs. coroutine)
    • design by committee (poorly explained, e.g. alternatives not explained)
      • customization points overload
  • Windows Thread Pool