Skip to content

fix: on COROSIO, the public headers include nothing of Boost.Asio - #52

Merged
pgit merged 1 commit into
masterfrom
capy-buffers
Nov 24, 2026
Merged

pgit merged 1 commit into
masterfrom
capy-buffers

Conversation

@pgit

@pgit pgit commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Fixes #39: on COROSIO, no public header includes anything of Boost.Asio any more.

Since Boost.HTTP replaced Beast (#46), anyhttp's own buffers were the only thing still bringing Asio into a COROSIO program. Reader::read_some(), Writer::write() and Writer::write_eof() took Asio's buffers, and corosio/runtime.hpp included <boost/asio/buffer.hpp> and capy's Asio bridge for the io:: helpers.

What changes

  • The runtime layer names its buffers. ConstBuffer and MutableBuffer are Asio's on ASIO and capy's on COROSIO. make_buffer() makes either one: boost::asio::buffer() on ASIO, boost::capy::make_buffer() on COROSIO.
  • Reader and Writer take them. Their coroutines convert to Asio's buffers for the backends, which don't change. On COROSIO, write_eof() takes a capy buffer, and read_some() takes a capy buffer or a capy buffer sequence. The overloads for Asio's buffer sequences are now ASIO-only. Nothing changes on ASIO: the aliases are the types the API had before.
  • The io:: stream helpers moved (read_some, write, peek, receive, wait_readable). They take Asio's buffers, so they went from {asio,corosio}/runtime.hpp into {asio,corosio}/net.hpp, which aren't public. The code itself is unchanged.
  • Code that builds on both runtimes now makes its buffers with make_buffer(): the request handlers, the shared tests, the docs snippets and examples, client_main, the README and test/package/consumer.cpp. Capy's buffers have no operator+, so that code writes buffer += n instead of buffer + n. The docs and CLAUDE.md say so.

Tests

The issue asks for two; both are in:

  • A header check. A COROSIO tree compiles every public header into test_all on its own, in a file of its own (test/CMakeLists.txt), and fails with #error if BOOST_ASIO_VERSION is defined. The public headers are the ones cmake/install.cmake installs, minus asio/ and corosio/. I checked that the check fails when Asio is included.
  • A test with capy's buffers. CoroutineApi.WHEN_ending_a_body_with_a_capy_buffer_THEN_the_peer_gets_all_of_it (COROSIO only) ends a body with write_eof(boost::capy::make_buffer(...)). It reads into a sequence of capy buffers and spells them the way capy does, not through make_buffer().

Run locally:

  • gtest-parallel is green on build/ (626 tests), build-corosio/ (591) and build-h2v2/. One ExternalTLS.h2load/HTTP2 failure in an earlier build/ run passed when run alone and on the rerun.
  • build-corosio-gcc/ fails only ClientAsync.Recursion ×3, which fails there on master too.
  • build-gcc/ builds; I didn't run its suite.
  • scripts/check_package.sh passes: install, embed-asio and embed-corosio.
  • The Asio-boundary check from CLAUDE.md prints nothing in build-corosio/.
  • The docs target builds.

Open

Writer::write_eof() takes one capy buffer on COROSIO, not a buffer sequence. A sequence version would have to write all but the last buffer before ending the body. I left it out because nothing needs it yet.

🤖 Generated with Claude Code

Since Boost.HTTP replaced Beast (#46), what still brought Asio into a program on COROSIO was
anyhttp's own buffers: Reader::read_some() and Writer::write()/write_eof() took Asio's, and
corosio/runtime.hpp included <boost/asio/buffer.hpp> and capy's bridge for the io:: helpers.

The runtime layer now names its buffers, ConstBuffer and MutableBuffer, Asio's on ASIO and capy's
on COROSIO, and make_buffer() makes either: boost::asio::buffer() or capy::make_buffer(). The
coroutines of Reader and Writer take them, and convert to Asio's for the backends, which are
written in those as before. So on COROSIO, write_eof() takes a capy buffer, and read_some() a capy
buffer or sequence; the overloads for Asio's buffer sequences are ASIO's only. The io:: stream
helpers, which take Asio's buffers, move from runtime.hpp to net.hpp, which is not public.

Code that builds with either runtime makes its buffers with make_buffer(): the request handlers,
the shared tests, the docs and the programs. Capy's buffers have no operator+, so that code
writes buffer += n.

A COROSIO tree compiles every public header on its own into test_all, and fails if one of them
defines BOOST_ASIO_VERSION; CoroutineApi ends a body with capy's buffers, spelled as capy does.

Fixes #39.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pgit
pgit merged commit aa95baa into master Nov 24, 2026
12 checks passed
@pgit
pgit deleted the capy-buffers branch November 24, 2026 13:55
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.

COROSIO: the public headers still need Boost.Asio

1 participant