Skip to content

Migrating from 0.6 to 1.0

简体中文 · Migration

PACE 1.0 is still in development. This guide grows with it: each pre-release adds the changes that need work on your side. Everything not listed here keeps working unchanged.

1.0.0-alpha.1: module layout

The library is now organized by module. Behavior and signatures are unchanged; include paths, xmake targets and the named-module interface changed.

Include paths

Each module has an umbrella header <pace/<module>.hpp>, and its content headers live in include/pace/<module>/. The simplest update is to include the umbrella header of each module you use.

0.6 1.0
<pace/task.hpp>, <pace/io_context.hpp>, <pace/run.hpp>, <pace/cancellation.hpp>, <pace/task_group.hpp>, <pace/operation.hpp>, <pace/this_context.hpp>, <pace/blocking.hpp>, <pace/platform.hpp>, <pace/io_backend.hpp> <pace/runtime.hpp>, or the same file name under <pace/runtime/…>
<pace/runtime.hpp> (the pace::runtime class) <pace/runtime.hpp> now includes the whole runtime; the class alone is <pace/runtime/runtime.hpp>
<pace/tcp.hpp>, <pace/udp.hpp>, <pace/ip.hpp>, <pace/stream_io.hpp> <pace/net.hpp>, or <pace/net/tcp.hpp> and so on
<pace/http.hpp> for HTTP/1.1 (http::app, get, serve, clients) <pace/http1.hpp>. <pace/http.hpp> is now the protocol-independent HTTP module
<pace/http_types.hpp>, <pace/http_router.hpp> <pace/http.hpp>, or <pace/http/types.hpp>, <pace/http/router.hpp>
<pace/http_services.hpp> <pace/gateway.hpp>
<pace/networking.hpp>, <pace/extensions.hpp>, <pace/application.hpp> Removed: include the module headers you use, or <pace/pace.hpp> for everything enabled
<pace/tls.hpp>, <pace/dns.hpp>, <pace/quic.hpp>, <pace/http2.hpp>, <pace/http3.hpp>, <pace/websocket.hpp>, <pace/net.hpp>, <pace/pace.hpp> Unchanged
<pace/detail/…> Removed. These were never public; they now live in the library's sources

One include keeps compiling but changes meaning: <pace/http.hpp>. Code that used it for HTTP/1.1 now fails with missing names such as pace::http::app or pace::http::get. Include <pace/http1.hpp> instead.

The pace::detail namespace no longer exists. Code that reached into it was relying on internals; there is no replacement.

xmake targets

Each module is its own static library with explicit dependencies, so depending on one module builds only that module and what it needs.

0.6 1.0
pace_runtime, pace_net, pace Unchanged
pace_extensions Removed: depend on pace_tls, pace_dns, pace_quic as needed
pace_application Removed: depend on pace_http1, pace_http2, pace_http3, pace_websocket as needed
— New: pace_http, header-only, the protocol-independent HTTP types and router; pulled in by the HTTP modules

The gateway (<pace/gateway.hpp>) is compiled into pace_http1 for now.

Named modules

import pace; still imports everything enabled. There is now also one named module per library module: pace.runtime, pace.net, pace.http, pace.http1, pace.gateway, pace.tls, pace.dns, pace.quic, pace.http2, pace.http3, pace.websocket. Each exports only its own names, so a program that uses TCP imports both pace.runtime and pace.net. The target is still pace_module, built with --modules=y. Build options

Compatibility aliases

tcp_stream, tcp_listener, ipv4_endpoint and listen_options remain available from <pace/net.hpp> (<pace/net/aliases.hpp>) and are deprecated, without a compiler warning yet: use pace::tcp::stream, pace::tcp::listener, pace::tcp::endpoint and pace::tcp::listen_options. They are removed in 1.0.0-alpha.2.

1.0.0-alpha.2: runtime and networking

task_group::cancel() ends the scope normally

A group cancelled with its own cancel() now returns from the scope instead of throwing operation_canceled: the body's value for a value-returning body, nothing for a void body. Code that caught operation_canceled around task_group::run or with_task_group after calling cancel() can drop that handler. A value-returning body that is cancelled before it produces a value still throws, and cancellation from outside the group (an enclosing with_cancellation, a deadline, io_context::stop()) still propagates as before.

0.x names removed

pace::tcp_stream, pace::tcp_listener, pace::ipv4_endpoint, pace::listen_options and <pace/net/aliases.hpp> are gone. Replace them with pace::tcp::stream, pace::tcp::listener, pace::tcp::endpoint and pace::tcp::listen_options; <pace/net.hpp> declares all four.

One operation per direction is enforced up front

A TCP read_some (or close_gracefully), write_all or listener::accept started while another one in the same direction is still suspended now throws std::logic_error immediately, as UDP already did. Before, a second read could take data meant for the first, and a second write could interleave its bytes with the first. Code that followed the documented one-read, one-write rule is unaffected.

Byte streams have one interface, in bytes

TCP, TLS and QUIC streams and UDP sockets now read and write std::byte spans only; the char and std::string_view overloads are gone. <pace/net/buffer.hpp> (included by <pace/net.hpp>) converts at the call site without copying. Code that still passes text fails to compile (no conversion to std::span<const std::byte> or std::span<std::byte>); nothing changes behaviour silently.

0.6 1.0
stream.write_all("text"), stream.write_all(std::string_view(data, size)) stream.write_all(pace::as_bytes("text")), stream.write_all(pace::as_bytes(std::string_view(data, size)))
stream.read_some(buffer) with a std::array<char, N>, std::vector<char> or std::span<char> stream.read_some(pace::as_writable_bytes(buffer))
pace::read_exact(stream, std::span<char>(text)), tcp::stream::read_exact(std::span<char>) pace::read_exact(stream, pace::as_writable_bytes(text))
socket.send_to("text", destination) socket.send_to(pace::as_bytes("text"), destination)
socket.receive_from(std::span<char>(buffer)) socket.receive_from(pace::as_writable_bytes(buffer))
quic_stream.try_read(std::span<char>(buffer)), quic_stream.try_write(text) quic_stream.try_read(pace::as_writable_bytes(buffer)), quic_stream.try_write(pace::as_bytes(text))
std::string_view(reinterpret_cast<const char*>(bytes.data()), bytes.size()) pace::as_text(bytes)
template <pace::tls::tls_byte_stream Transport>, tls_closeable, tls_resettable template <pace::byte_stream Transport>

Unchanged: calls that already pass std::byte spans, pace::write(stream, std::string), the owning pace::read_exact(stream, size) and stream.read_exact(size), and UDP send / receive.

A custom transport for tls::stream now has to satisfy pace::byte_stream: read_some(std::span<std::byte>), write_all(std::span<const std::byte>), shutdown_write(), close() noexcept and context() const noexcept. An adapter written for tls_byte_stream takes the byte spans and gains shutdown_write(); a QUIC-style adapter that had only finish_write() and reset() also adds close(). The new members on PACE's own streams are shutdown_write() on tcp::stream (FIN), tls::stream (close_notify) and quic::stream (FIN), and quic::stream::close().

Direct clients take client_options

The TCP, UDP and TLS one-call clients now take a trailing pace::client_options instead of an io_context& first argument, a blocking_options and a positional reply bound. The async forms always run on the calling context; .context, when set, must name that context and throws std::logic_error otherwise (move work with pace::on instead). Blocking forms run on a fresh context and reject .context.

0.6 1.0
tcp::connect(io, peer) tcp::connect(peer) on io, or tcp::connect(peer, {.context = &io}) to check it
tcp::async_exchange(io, peer, request, size, maximum) tcp::async_exchange(peer, request, size, {.max_reply_size = maximum})
tcp::exchange(peer, request, size, {.timeout = t}, maximum) tcp::exchange(peer, request, size, {.timeout = t, .max_reply_size = maximum})
udp::async_exchange(io, peer, request, capacity) udp::async_exchange(peer, request, {.max_reply_size = capacity})
udp::exchange(peer, request, {.timeout = t}, capacity) udp::exchange(peer, request, {.timeout = t, .max_reply_size = capacity})
udp::open(io) udp::open({.context = &io}) (registers the socket there, also before run())
tls::connect(io, configuration, peer, name), tls::connect(configuration, peer, name) tls::connect(peer, name, {.tls = &configuration})
tls::connect(io, peer, name) tls::connect(peer, name) (verified system trust)

blocking_options fields map one to one: timeout, deadline and cancellation keep their names. TCP socket options and the pre-connect hook for these calls go in .transport.

Result tasks rethrow state misuse

task<pace::result<T>> and co_await pace::as_result(task) are new in this release. They turn run-time failures, malformed arguments and length errors into the result's error code, but rethrow any other std::logic_error, such as a second concurrent read or a call on the wrong context, and exceptions that are not standard library types. See Errors for the mapping.

1.0.0-alpha.4 native DNS

--dns=y builds the native resolver and drops the c-ares dependency. Existing pace_dns consumers keep the same headers and dns::resolve signatures. dns::options::tries remains an unsigned from 1 to 10. Code that unpacks the three old dns::options members with a structured binding should use named fields.

System-server lookups now apply the platform search list and ndots. Append a trailing dot for an exact lookup. Explicit numeric servers also select exact-name lookups. With system servers, the default value of two attempts inherits system attempts when configured. To explicitly request two attempts, set use_system_attempts = false. The addresses for family::any can arrive in either IPv4 or IPv6 order. Resolver cancellation now cancels all active lookups and a second lookup can run concurrently. Common DNS error codes retain their numeric values and the category name is pace.dns. The two-argument dns::dns_over_tls(name, config) uses strict authentication. Move any DoT endpoint on port 53 to a dedicated DoT port such as 853. Use dns::dot_profile::opportunistic explicitly if your policy permits unauthenticated TLS and eventual plaintext fallback. Use dns::options::tcp_only to select direct plaintext TCP. DNS reference

HTTP fields

Change parameters that take std::vector<http::header_field>& for message headers or trailers to http::header_map&. Replace std::erase_if(fields, predicate) with fields.erase_if(predicate). Initializer lists, indexed access, iteration and push_back keep their existing syntax.

HTTP/1 routing with server options

Pass typed http::server_options to serve(listener, routes, options) to keep streaming routes active with admission and deadlines. In calls that previously passed a bare {} in the limits position, omit the argument or spell it http::limits{} to select the limits overload. The server reference describes the read and write budgets.

Explicit HTTP/1 connections and module imports

Rename http::client(connected_tcp_stream, ...) to http::connection_client(connected_tcp_stream, ...). Its send(request) operation keeps the same behavior. The name http::client now takes an io_context& and manages connections for URLs. Import pace.http_client for the pool and the URL overloads with an explicit protocol selector.