Skip to content

[RFC] Add initial C++20 coroutine support #653

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

SidneyCogdill
Copy link

@SidneyCogdill SidneyCogdill commented Apr 8, 2025

The initial C++20 coroutine support. I may implement C++26 sender receiver support later, once I fully grasped its design (ref: stdexec).

The async version of the socket is placed under zmq::async::corral. It's implemented for corral but any open coroutine implementation can co_await on the send / recv operations. Boost.Cobalt is another open coroutine implementation.

Issues:

  1. The multipart send/receive cancellation isn't covered in the test cases.
  2. Relies on Boost.Asio. the standalone version of Asio isn't supported yet (but should be trivial to do so; I'm just tired currently and pushing the work up until now)
  3. Cancellation only works with corral currently because C++20 coroutine doesn't have a standardized way to do cancellation (Note that C++26 sender receiver has standardized cancellation support)
  4. Many code duplication, because clangd doesn't give helpful auto completions within function templates.
  5. It's strictly single thread concurrency as it's written for corral. 1:N multiplexing can be safely done by running multiple io_context in parallel. M:N multiplexing isn't possible currently with corral (Note that C++26 sender receiver does have proper M:N multiplexing)
  6. I didn't test it on Windows, only on Linux. It should work but I don't know.
  7. The comments are largely incomplete. I will write them properly in a follow-up commit.
  8. No documentations or examples. Again will do them in follow-up commits.

Alternatively wait for my implementation for sender receiver support (again, once I've grasped it myself), which should resolve 3 and 5.

Also refer to #400

@SidneyCogdill SidneyCogdill changed the title Add initial C++20 coroutine support [RFC] Add initial C++20 coroutine support Apr 8, 2025
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