diff --git a/.cursor/rules/doc-awaitable.mdc b/.cursor/rules/doc-awaitable.mdc index 0aeba1064..a71cdb2c1 100644 --- a/.cursor/rules/doc-awaitable.mdc +++ b/.cursor/rules/doc-awaitable.mdc @@ -12,7 +12,7 @@ alwaysApply: false - **`@return`** — Describe the returned aggregate and its elements. The first element is always `error_code`. Name and describe each subsequent element (e.g. "bytes_transferred", "endpoint"). Note that the result is customarily destructured by the caller. - **Error conditions** — Document the notable `error_code` values or conditions that may appear in the first element. E.g. `capy::cond::canceled` if the stop token was activated or the i/o object's `cancel()` was called, EOF conditions, protocol-specific errors, etc. State that error codes should be compared to error conditions, not specific values. - **`@throws`** — Typically only for precondition violations. State which preconditions trigger exceptions, or state that no exceptions are thrown during normal operation. -- **Cancellation** — State that the operation supports cancellation via `stop_token` propagated through the IoAwaitable protocol, or via the i/o object's `cancel()` member. State that the resulting error compares equal to `capy::cond::canceled`. +- **Cancellation** — State that the operation supports cancellation via `stop_token` propagated through the ContextAwaitable protocol, or via the i/o object's `cancel()` member. State that the resulting error compares equal to `capy::cond::canceled`. - **`@par Example`** — Two or three `@code` blocks showing different usage patterns: typical happy path with destructuring, error handling, cancellation, different overloads, etc. - **`@note` / `@par Remarks`** — Behavioral gotchas. E.g. "This operation may not read all of the requested bytes." Or equivalence to another overload. - **`@tparam`** — For non-variadic template parameters. State the concept requirement (e.g. "The type must satisfy the *AsyncStream* concept"). Don't document `Args...`. diff --git a/README.md b/README.md index 2063d0e3a..967e8f193 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ # Boost.Corosio -Boost.Corosio is a coroutine-only I/O library for C++20 that provides asynchronous networking primitives with automatic executor affinity propagation. Every operation returns an awaitable that integrates with the _IoAwaitable_ protocol, ensuring your coroutines resume on the correct executor without manual dispatch. +Boost.Corosio is a coroutine-only I/O library for C++20 that provides asynchronous networking primitives with automatic executor affinity propagation. Every operation returns an awaitable that integrates with the _ContextAwaitable_ protocol, ensuring your coroutines resume on the correct executor without manual dispatch. ## Quick Start diff --git a/doc/.vale/styles/Corosio/Terminology.yml b/doc/.vale/styles/Corosio/Terminology.yml index 2cddf18eb..fe98daac5 100644 --- a/doc/.vale/styles/Corosio/Terminology.yml +++ b/doc/.vale/styles/Corosio/Terminology.yml @@ -13,7 +13,7 @@ # `launch`/`spawn`-bearing identifier in the library and the pages is either # snake_case (`launch_one`, `launch_all`, `spawn_work`, `co_spawn`, # `launch_policies`, the snippet tag `4b_launching`) or a `launcher` compound -# (`when_any_io_launcher`, `launchable`, `relaunch`, `launchers`). `_` is a word +# (`when_any_results_launcher`, `launchable`, `relaunch`, `launchers`). `_` is a word # character, so the `\b` after the stem already excludes the snake_case forms, # and the inflection list below is deliberately limited to VERB endings so it # cannot reach `launcher`. On top of that, `.vale.ini`'s `TokenIgnores` blanks diff --git a/doc/.vale/styles/config/vocabularies/Corosio/accept.txt b/doc/.vale/styles/config/vocabularies/Corosio/accept.txt index 037652c3e..186131452 100644 --- a/doc/.vale/styles/config/vocabularies/Corosio/accept.txt +++ b/doc/.vale/styles/config/vocabularies/Corosio/accept.txt @@ -105,7 +105,7 @@ # --- C++ terms used adjectivally or nominally in running prose ------------------ # # Language keywords belong here, and several already did (const, nullptr, nothrow, -# enum, bool). The line against bare identifiers below is about SYMBOLS: `io_result` +# enum, bool). The line against bare identifiers below is about SYMBOLS: `results` # has a generated reference page, so leaving it unlinked in prose is a real missed # `cpp:` link (style guide B1). A keyword has no page and nothing to link to, so B1 # offers no remedy and the alert can never be actioned -- it is noise, not a signal. @@ -252,7 +252,7 @@ # reference page ever appears for one, delete its line here and link it instead. (?i)mockets? (?i)socket_pair -(?i)io_result +(?i)results (?i)const_buffer (?i)mutable_buffer (?i)buffer_slice diff --git a/doc/STYLE_GUIDE.md b/doc/STYLE_GUIDE.md index 978215628..5db0108ad 100644 --- a/doc/STYLE_GUIDE.md +++ b/doc/STYLE_GUIDE.md @@ -164,7 +164,7 @@ as vocabulary is added — extend it rather than letting synonyms drift.)* | callback passed to `run_async` | **completion handler** | handler (bare), callback | | a `task` value | **task** | coroutine (the language feature), coro | | the C++20 language feature | **coroutine** | coro, async function | -| awaitable satisfying `IoAwaitable` | **I/O awaitable** | awaitable (bare, when the concept is meant) | +| awaitable satisfying `ContextAwaitable` | **I/O awaitable** | awaitable (bare, when the concept is meant) | | object that listens for inbound connections | **acceptor** | listener, server socket, listening socket | | an address plus a port | **endpoint** | address (when the port is included), socket address | | the machine at the other end of a connection | **peer** | remote, other side, partner | diff --git a/doc/design/physical-structure.md b/doc/design/physical-structure.md index a6d0ac2b7..1e9cfddad 100644 --- a/doc/design/physical-structure.md +++ b/doc/design/physical-structure.md @@ -129,7 +129,7 @@ private: auto await_suspend( std::coroutine_handle<> h, - capy::io_env const* env ) -> std::coroutine_handle<> + capy::await_context const* env ) -> std::coroutine_handle<> { // Virtual dispatch through implementation - type-erased return self_.get().read_some( h, env->executor, @@ -229,7 +229,7 @@ private: auto await_suspend( std::coroutine_handle<> h, - capy::io_env const* env ) -> std::coroutine_handle<> + capy::await_context const* env ) -> std::coroutine_handle<> { // Virtual dispatch through concrete implementation return self_.get().connect( h, env->executor, @@ -375,7 +375,7 @@ private: auto await_suspend( std::coroutine_handle<> h, - capy::io_env const* env ) -> std::coroutine_handle<> + capy::await_context const* env ) -> std::coroutine_handle<> { // Direct call to backend impl - no vtable, inlinable return self_.get_impl().read_some( h, env->executor, diff --git a/doc/error-handling-rulebook.md b/doc/error-handling-rulebook.md index 27a2f2135..34051f153 100644 --- a/doc/error-handling-rulebook.md +++ b/doc/error-handling-rulebook.md @@ -44,10 +44,10 @@ by classifying its failures: | Situation | Shape | |---|---| | Sync, no payload | `[[nodiscard]] std::error_code f(...) noexcept` | -| Sync, with payload | `[[nodiscard]] capy::io_result f(...) noexcept` | -| Async | the awaitable completes with `io_result<...>` — initiators never throw | +| Sync, with payload | `[[nodiscard]] capy::results f(...) noexcept` | +| Async | the awaitable completes with `results<...>` — initiators never throw | -`io_result` is `std::tuple`, so results +`results` is `std::tuple`, so results destructure; the sync and async surfaces share one idiom: ```cpp @@ -58,7 +58,7 @@ auto [ec2, ep] = make_endpoint("10.0.0.1:80"); // factory ``` The payload always rides in the return — the `make_*` factories -return `io_result` with a default-constructed payload on failure. +return `results` with a default-constructed payload on failure. Every awaitable-returning initiator is `[[nodiscard]]`: a discarded awaitable is a silent no-op that also drops any pre-set completion. @@ -99,7 +99,7 @@ they own, race-free, before the call?** Corollary: an operation with no realistic failure on a valid open object (`size()`, `release()`, `available()`) stays on the throwing -channel — an `io_result` return would tax every correct call site to +channel — a `results` return would tax every correct call site to carry a bit that is always "you have a bug". ## 4. The Closed-Object Condition diff --git a/doc/lint/extract-docstrings.mjs b/doc/lint/extract-docstrings.mjs index c5283a693..ab5f08214 100644 --- a/doc/lint/extract-docstrings.mjs +++ b/doc/lint/extract-docstrings.mjs @@ -26,9 +26,9 @@ // BOTH Doxygen doc-comment forms are extracted: `/** ... */` blocks and runs of // consecutive `///` lines. A run of `///` lines is ONE doc comment attached to // the declaration that follows it, which is how Doxygen and MrDocs read it, and -// MrDocs really does publish that prose — `io_result.hpp:49`'s +// MrDocs really does publish that prose — `results.hpp:49`'s // `/// The error code from the operation.` renders on both -// `reference/boost/corosio/io_result.html` and `reference/boost/corosio/io_result/ec.html`. +// `reference/boost/corosio/results.html` and `reference/boost/corosio/results/ec.html`. // Until 2026-08 only the `/** */` form was extracted, so 86 published doc lines // across 25 headers were invisible to every Vale rule and to the C2 checker, // including the four the Phase-4 exit promoted to merge-blocking gates. It was diff --git a/doc/modules/ROOT/pages/4.guide/4d.sockets.adoc b/doc/modules/ROOT/pages/4.guide/4d.sockets.adoc index 2f7692184..fa5eb97e4 100644 --- a/doc/modules/ROOT/pages/4.guide/4d.sockets.adoc +++ b/doc/modules/ROOT/pages/4.guide/4d.sockets.adoc @@ -89,7 +89,7 @@ The `connect()` operation initiates a TCP connection: include::example$snippets/4d_sockets.cpp[tag=connect,indent=0] ---- -This returns an `io_result<>` that you can unpack with structured bindings. +This returns a `results<>` that you can unpack with structured bindings. === Connection Errors diff --git a/doc/modules/ROOT/pages/4.guide/4h.timers.adoc b/doc/modules/ROOT/pages/4.guide/4h.timers.adoc index 42a52055e..ed7472d56 100644 --- a/doc/modules/ROOT/pages/4.guide/4h.timers.adoc +++ b/doc/modules/ROOT/pages/4.guide/4h.timers.adoc @@ -107,13 +107,13 @@ Whichever finishes first decides the outcome: include::example$snippets/4h_timers.cpp[tag=timeout_read,indent=0] ---- -If the inner operation wins, its `io_result` is returned unchanged, +If the inner operation wins, its `results` is returned unchanged, error or success, payload and all. If the deadline wins, the inner operation is cancelled and `timeout()` produces its own result. `ec` is `capy::cond::timeout`, and any payload such as a byte count is default-initialized. It is not whatever the cancelled operation happened to leave behind. Because the deadline-win path default-initializes -that payload, the inner operation's `io_result` payload type must be +that payload, the inner operation's `results` payload type must be default constructible. `timeout()` also accepts an absolute deadline: @@ -157,7 +157,7 @@ requested delay would be worse than a hard failure. == Composing with Other Operations -Because `timeout()` takes any awaitable that yields an `io_result`, +Because `timeout()` takes any awaitable that yields a `results`, it composes with anything Corosio returns, not just socket reads. A connect-with-retry loop pairs `timeout()` for the per-attempt deadline with `delay()` for the pause between attempts: diff --git a/doc/modules/ROOT/pages/4.guide/4m.error-handling.adoc b/doc/modules/ROOT/pages/4.guide/4m.error-handling.adoc index fe1a47965..444e54d5c 100644 --- a/doc/modules/ROOT/pages/4.guide/4m.error-handling.adoc +++ b/doc/modules/ROOT/pages/4.guide/4m.error-handling.adoc @@ -11,7 +11,7 @@ = Error Handling :page-mode: how-to -Corosio reports I/O errors through the `io_result` type, which carries an +Corosio reports I/O errors through the `results` type, which carries an error code alongside any values produced by the operation. [#one-channel] @@ -20,9 +20,9 @@ error code alongside any values produced by the operation. Every fallible operation reports through exactly one channel: * *Expected runtime conditions return the error.* Synchronous - operations return `std::error_code` (or `io_result` when a + operations return `std::error_code` (or `results` when a payload rides along — `seek()`, the `make_*` factories), and - asynchronous operations complete with `io_result<...>`. Every + asynchronous operations complete with `results<...>`. Every error-returning function is `+[[nodiscard]]+`. * *Misuse of a documented precondition throws* `std::system_error` — for example `release()`, `set_option()`, or `get_option()` on a @@ -104,9 +104,9 @@ include::example$snippets/4m_error_handling.cpp[tag=assume] ---- ==== -== The io_result Type +== The `results` Type -`io_result` is an alias for `std::tuple`: +`results` is an alias for `std::tuple`: the error code always comes first, followed by any values the operation produced. Because it is a `std::tuple`, results interoperate with the whole tuple API — structured bindings, `std::tie`, `std::get`, @@ -145,7 +145,7 @@ value for you. == Throwing on Error -`io_result` never throws on its own. To turn an error into an exception, +`results` never throws on its own. To turn an error into an exception, test `ec` and throw explicitly: [source,cpp] diff --git a/doc/modules/ROOT/pages/4.guide/4q.udp.adoc b/doc/modules/ROOT/pages/4.guide/4q.udp.adoc index 2897f96b0..a43cac056 100644 --- a/doc/modules/ROOT/pages/4.guide/4q.udp.adoc +++ b/doc/modules/ROOT/pages/4.guide/4q.udp.adoc @@ -298,4 +298,4 @@ cost in the kernel, so a server can run several receivers in parallel. protocol-level background * xref:4.guide/4d.sockets.adoc[Sockets] — generic socket options and lifetime rules * xref:4.guide/4f.endpoints.adoc[Endpoints] — IP address and port construction -* xref:4.guide/4m.error-handling.adoc[Error Handling] — the `io_result` pattern +* xref:4.guide/4m.error-handling.adoc[Error Handling] — the `results` pattern diff --git a/doc/modules/ROOT/pages/4.guide/4r.wait.adoc b/doc/modules/ROOT/pages/4.guide/4r.wait.adoc index 368532d98..1e5e93a59 100644 --- a/doc/modules/ROOT/pages/4.guide/4r.wait.adoc +++ b/doc/modules/ROOT/pages/4.guide/4r.wait.adoc @@ -117,7 +117,7 @@ include::example$snippets/4r_wait.cpp[tag=wait_cancel,indent=0] cpp:timeout[] composes with `wait()` the same way it does with the other socket operations, since `wait()` -yields an `io_result` like any other awaitable: +yields a `results` like any other awaitable: [source,cpp] ---- diff --git a/doc/modules/ROOT/pages/4.guide/4t.lifetime.adoc b/doc/modules/ROOT/pages/4.guide/4t.lifetime.adoc index 331a2455f..e6a319fa3 100644 --- a/doc/modules/ROOT/pages/4.guide/4t.lifetime.adoc +++ b/doc/modules/ROOT/pages/4.guide/4t.lifetime.adoc @@ -117,7 +117,7 @@ Check each of these: still held by the caller after a `post` that threw. Never two of these, and never none. . *The environment outlives the work it is lent to.* An inner task or - awaitable may use an `io_env`, stop source or stop token held in another + awaitable may use an `await_context`, stop source or stop token held in another member. Declare that member first, so it is destroyed after the work. . *End an operation before what it references.* A wrapper that caches an inner operation ends it before destroying or replacing the object the operation diff --git a/doc/modules/ROOT/pages/glossary.adoc b/doc/modules/ROOT/pages/glossary.adoc index 1e7035330..b3668277c 100644 --- a/doc/modules/ROOT/pages/glossary.adoc +++ b/doc/modules/ROOT/pages/glossary.adoc @@ -19,7 +19,7 @@ An I/O object that listens for and accepts incoming connections. See cpp:tcp_acceptor[] and xref:4.guide/4e.tcp-acceptor.adoc[Acceptors Guide]. Affine Awaitable:: An awaitable type that implements the affine protocol. -It receives an `io_env const*` in `await_suspend`, carrying the executor, +It receives an `await_context const*` in `await_suspend`, carrying the executor, stop token, and frame allocator, to ensure correct executor affinity. Affinity:: @@ -135,7 +135,7 @@ I/O Stream:: An I/O object that supports reading and writing data. Base class is `corosio::io_stream`. -io_result:: +results:: The result type for Corosio operations, containing an error code and optional values. Supports structured bindings. diff --git a/doc/modules/ROOT/pages/index.adoc b/doc/modules/ROOT/pages/index.adoc index 1ebca8ec8..0989e5423 100644 --- a/doc/modules/ROOT/pages/index.adoc +++ b/doc/modules/ROOT/pages/index.adoc @@ -17,7 +17,7 @@ asynchronous networking primitives with automatic executor affinity propagation. Corosio provides asynchronous I/O operations designed from the ground up for C++20 coroutines. Every operation returns an awaitable that integrates with -the _IoAwaitable_ protocol, ensuring your coroutines resume on the correct +the _ContextAwaitable_ protocol, ensuring your coroutines resume on the correct executor without manual dispatch. * cpp:io_context[] — Event loop for processing asynchronous operations @@ -54,7 +54,7 @@ callback-based interfaces. parameters, not through thread-local storage. When an I/O operation completes, it resumes your coroutine through the executor you provided. -**Structured bindings.** Results use `io_result` which supports structured +**Structured bindings.** Results use `results` which supports structured bindings: `auto [ec, n] = co_await s.read_some(buf)`. See xref:4.guide/4m.error-handling.adoc[Error Handling] for how to handle the error code. diff --git a/doc/scheduler.md b/doc/scheduler.md index 70d713315..896b41a37 100644 --- a/doc/scheduler.md +++ b/doc/scheduler.md @@ -9,7 +9,7 @@ Asio and Corosio take fundamentally different approaches to coroutine management | Aspect | Asio | Corosio | |--------|------|---------| | Symmetric transfer | Simulated via `pump()` loop | Native language mechanism | -| Type system | Closed (`asio::awaitable` only) | Open (`IoAwaitable` concept) | +| Type system | Closed (`asio::awaitable` only) | Open (`ContextAwaitable` concept) | | `await_suspend` return | `void` | `coroutine_handle` | | I/O initiation timing | `after_suspend_fn_` callback | TBD | @@ -62,7 +62,7 @@ Corosio's `task` returns `coroutine_handle` from `await_suspend`, enabling co ```cpp // task::await_suspend - returns coroutine_handle -std::coroutine_handle<> await_suspend(std::coroutine_handle<> cont, io_env const* env) +std::coroutine_handle<> await_suspend(std::coroutine_handle<> cont, await_context const* env) { h_.promise().set_continuation(cont, env->executor); h_.promise().set_environment(env); @@ -104,14 +104,14 @@ This creates a closed type system where only `asio::awaitable` coroutines can ### Corosio's Open System -Corosio uses the `IoAwaitable` concept, allowing any conforming type to participate: +Corosio uses the `ContextAwaitable` concept, allowing any conforming type to participate: ```cpp template auto transform_awaitable(Awaitable&& a) { using A = std::decay_t; - if constexpr (IoAwaitable) + if constexpr (ContextAwaitable) { return transform_awaiter{ std::forward(a), this}; @@ -123,10 +123,10 @@ auto transform_awaitable(Awaitable&& a) The `await_suspend` signature accepts the execution environment: ```cpp -std::coroutine_handle<> await_suspend(std::coroutine_handle<> cont, io_env const* env) +std::coroutine_handle<> await_suspend(std::coroutine_handle<> cont, await_context const* env) ``` -This design allows third-party awaitable types to integrate with Corosio's I/O system by satisfying the `IoAwaitable` concept. +This design allows third-party awaitable types to integrate with Corosio's I/O system by satisfying the `ContextAwaitable` concept. ## I/O Initiation Timing diff --git a/include/boost/corosio/connect.hpp b/include/boost/corosio/connect.hpp index d20e62487..7ea96ebd5 100644 --- a/include/boost/corosio/connect.hpp +++ b/include/boost/corosio/connect.hpp @@ -13,7 +13,7 @@ #include #include -#include +#include #include #include @@ -38,7 +38,7 @@ the resolver uses for "no results" in posix_resolver_service. The operation is a plain coroutine; cancellation is propagated to the - inner per-endpoint connect via the affine awaitable protocol on io_env. + inner per-endpoint connect via the affine awaitable protocol on await_context. */ namespace boost::corosio { @@ -71,7 +71,7 @@ template ConnectCondition&, std::error_code const&, typename Socket::endpoint_type const&> -capy::task> +capy::task> connect(Socket& s, Range endpoints, ConnectCondition cond); template @@ -82,7 +82,7 @@ template ConnectCondition&, std::error_code const&, typename Socket::endpoint_type const&> -capy::task> +capy::task> connect(Socket& s, Iter begin, Iter end, ConnectCondition cond); /** Asynchronously connect a socket by trying each endpoint in a range. @@ -110,7 +110,7 @@ connect(Socket& s, Iter begin, Iter end, ConnectCondition cond); (`connect(s, begin, end)`) to avoid the copy. @return An awaitable completing with - `capy::io_result`: + `capy::results`: - on success: default `error_code` and the connected endpoint; - on failure of all attempts: the error from the last attempt and a default-constructed endpoint; @@ -136,7 +136,7 @@ template requires std::convertible_to< std::ranges::range_reference_t, typename Socket::endpoint_type> -capy::task> +capy::task> connect(Socket& s, Range endpoints) { detail::default_connect_condition cond; @@ -173,7 +173,7 @@ template ConnectCondition&, std::error_code const&, typename Socket::endpoint_type const&> -capy::task> +capy::task> connect(Socket& s, Range endpoints, ConnectCondition cond) { using endpoint_type = typename Socket::endpoint_type; @@ -221,7 +221,7 @@ connect(Socket& s, Range endpoints, ConnectCondition cond) @param begin The first candidate. @param end One past the last candidate. - @return An awaitable completing with `capy::io_result`: + @return An awaitable completing with `capy::results`: - on success: default `error_code` and the iterator of the successful endpoint; - on failure of all attempts: the error from the last attempt @@ -236,7 +236,7 @@ template requires std::convertible_to< std::iter_reference_t, typename Socket::endpoint_type> -capy::task> +capy::task> connect(Socket& s, Iter begin, Iter end) { return corosio::connect( @@ -273,7 +273,7 @@ template ConnectCondition&, std::error_code const&, typename Socket::endpoint_type const&> -capy::task> +capy::task> connect(Socket& s, Iter begin, Iter end, ConnectCondition cond) { using endpoint_type = typename Socket::endpoint_type; diff --git a/include/boost/corosio/delay.hpp b/include/boost/corosio/delay.hpp index 52189e6a0..ad41d5f53 100644 --- a/include/boost/corosio/delay.hpp +++ b/include/boost/corosio/delay.hpp @@ -16,8 +16,8 @@ #include #include #include -#include -#include +#include +#include #include #include @@ -158,7 +158,7 @@ class delay_awaitable the wait was published to the timer service. */ std::coroutine_handle<> - await_suspend(std::coroutine_handle<> h, capy::io_env const* env) + await_suspend(std::coroutine_handle<> h, capy::await_context const* env) { if (env->stop_token.stop_requested()) { @@ -184,7 +184,7 @@ class delay_awaitable } /// Return empty on expiry, `error::canceled` if stop won. - [[nodiscard]] capy::io_result<> await_resume() noexcept + [[nodiscard]] capy::results<> await_resume() noexcept { if (canceled_) return {capy::error::canceled}; @@ -294,7 +294,7 @@ class clock_delay_awaitable the wait was published to the timer service. */ std::coroutine_handle<> - await_suspend(std::coroutine_handle<> h, capy::io_env const* env) + await_suspend(std::coroutine_handle<> h, capy::await_context const* env) { if (env->stop_token.stop_requested()) { @@ -320,7 +320,7 @@ class clock_delay_awaitable } /// Return empty on deadline, `error::canceled` if stop won. - [[nodiscard]] capy::io_result<> await_resume() noexcept + [[nodiscard]] capy::results<> await_resume() noexcept { if (canceled_) return {capy::error::canceled}; @@ -332,7 +332,7 @@ class clock_delay_awaitable /** Suspend the current coroutine for a duration. - Returns an IoAwaitable that completes at or after the + Returns a ContextAwaitable that completes at or after the specified duration, or earlier if the environment's stop token is activated. Zero or negative durations complete synchronously. @@ -342,7 +342,7 @@ class clock_delay_awaitable @param dur The duration to wait. - @return A @ref delay_awaitable yielding `io_result<>`. + @return A @ref delay_awaitable yielding `results<>`. */ template [[nodiscard]] delay_awaitable @@ -353,13 +353,13 @@ delay(std::chrono::duration dur) noexcept /** Suspend the current coroutine until a time point. - Returns an IoAwaitable that completes at or after `tp`, or + Returns a ContextAwaitable that completes at or after `tp`, or earlier if the environment's stop token is activated. Time points already reached complete synchronously. @param tp The steady-clock time point to wait until. - @return A @ref delay_awaitable yielding `io_result<>`. + @return A @ref delay_awaitable yielding `results<>`. */ [[nodiscard]] inline delay_awaitable delay(std::chrono::steady_clock::time_point tp) noexcept @@ -369,7 +369,7 @@ delay(std::chrono::steady_clock::time_point tp) noexcept /** Suspend the current coroutine until a time point on `Clock`. - Returns an IoAwaitable that completes at or after the first + Returns a ContextAwaitable that completes at or after the first observation of `Clock::now() >= tp`, or earlier if the environment's stop token is activated. The wait is one or more bounded steady-clock waits, re-reading `Clock::now()` after @@ -395,7 +395,7 @@ delay(std::chrono::steady_clock::time_point tp) noexcept @param tp The time point to wait until. - @return A @ref clock_delay_awaitable yielding `io_result<>`. + @return A @ref clock_delay_awaitable yielding `results<>`. */ template requires(!std::same_as) && diff --git a/include/boost/corosio/detail/buffer_param.hpp b/include/boost/corosio/detail/buffer_param.hpp index 397b60cfb..89a9f6983 100644 --- a/include/boost/corosio/detail/buffer_param.hpp +++ b/include/boost/corosio/detail/buffer_param.hpp @@ -143,7 +143,7 @@ namespace boost::corosio { stream->async_write_some_impl(bufs, h); } - io_result await_resume() { return stream->get_result(); } + results await_resume() { return stream->get_result(); } }; // Virtual implementation - unrolls immediately diff --git a/include/boost/corosio/detail/op_base.hpp b/include/boost/corosio/detail/op_base.hpp index 25660c32a..59a46c361 100644 --- a/include/boost/corosio/detail/op_base.hpp +++ b/include/boost/corosio/detail/op_base.hpp @@ -12,9 +12,9 @@ #include #include -#include +#include #include -#include +#include #include #include @@ -23,7 +23,7 @@ namespace boost::corosio::detail { -/* CRTP base for awaitables that return io_result. +/* CRTP base for awaitables that return results. Derived classes must provide: @@ -55,12 +55,12 @@ class bytes_op_base return static_cast(ec_); } - [[nodiscard]] capy::io_result await_resume() const noexcept + [[nodiscard]] capy::results await_resume() const noexcept { return {ec_, bytes_}; } - auto await_suspend(std::coroutine_handle<> h, capy::io_env const* env) + auto await_suspend(std::coroutine_handle<> h, capy::await_context const* env) -> std::coroutine_handle<> { token_ = env->stop_token; @@ -80,7 +80,7 @@ class bytes_op_base } }; -/* CRTP base for awaitables that return io_result for a +/* CRTP base for awaitables that return results for a moved-out result object (e.g. the resolver's result lists). Derived classes must provide: @@ -112,12 +112,12 @@ class value_op_base return static_cast(ec_); } - [[nodiscard]] capy::io_result await_resume() const noexcept + [[nodiscard]] capy::results await_resume() const noexcept { return {ec_, std::move(value_)}; } - auto await_suspend(std::coroutine_handle<> h, capy::io_env const* env) + auto await_suspend(std::coroutine_handle<> h, capy::await_context const* env) -> std::coroutine_handle<> { token_ = env->stop_token; @@ -135,7 +135,7 @@ class value_op_base } }; -/* CRTP base for awaitables that return io_result<>. +/* CRTP base for awaitables that return results<>. Derived classes must provide: @@ -165,12 +165,12 @@ class void_op_base return static_cast(ec_); } - [[nodiscard]] capy::io_result<> await_resume() const noexcept + [[nodiscard]] capy::results<> await_resume() const noexcept { return {ec_}; } - auto await_suspend(std::coroutine_handle<> h, capy::io_env const* env) + auto await_suspend(std::coroutine_handle<> h, capy::await_context const* env) -> std::coroutine_handle<> { token_ = env->stop_token; diff --git a/include/boost/corosio/detail/timeout_awaitable.hpp b/include/boost/corosio/detail/timeout_awaitable.hpp index a3dcb72e1..f83baadd9 100644 --- a/include/boost/corosio/detail/timeout_awaitable.hpp +++ b/include/boost/corosio/detail/timeout_awaitable.hpp @@ -17,9 +17,9 @@ #include #include #include -#include +#include #include -#include +#include #include #include @@ -30,7 +30,7 @@ #include #include -/* Races an inner IoAwaitable against a timer via a shared +/* Races an inner ContextAwaitable against a timer via a shared stop_source. await_suspend arms the timer by launching a fire-and-forget timeout_coro, then starts the inner op with an interposed stop_token. Whichever completes first signals @@ -50,19 +50,19 @@ namespace boost::corosio::detail { -// Local stand-in for capy::detail's io_result trait: corosio must not +// Local stand-in for capy::detail's `results` trait: corosio must not // reach into capy::detail, but the result-mapping switch in -// await_resume needs to distinguish io_result from other return types. +// await_resume needs to distinguish `results` from other return types. template -struct is_io_result : std::false_type +struct is_results : std::false_type {}; template -struct is_io_result> : std::true_type +struct is_results> : std::true_type {}; template -inline constexpr bool is_io_result_v = is_io_result::value; +inline constexpr bool is_results_v = is_results::value; /** Awaitable adapter that cancels an inner operation after a deadline. @@ -71,9 +71,9 @@ inline constexpr bool is_io_result_v = is_io_result::value; Parent cancellation is forwarded via stop_callback. The timer is constructed internally in `await_suspend` from the - execution context in `io_env`. + execution context in `await_context`. - @tparam A The inner IoAwaitable type (decayed). + @tparam A The inner ContextAwaitable type (decayed). */ template struct timeout_awaitable @@ -94,7 +94,7 @@ struct timeout_awaitable // environment it was given. std::stop_source stop_src_; std::stop_token parent_token_; - capy::io_env inner_env_; + capy::await_context inner_env_; A inner_; std::optional timer_; time_point deadline_; @@ -149,7 +149,7 @@ struct timeout_awaitable return inner_.await_ready(); } - auto await_suspend(std::coroutine_handle<> h, capy::io_env const* env) + auto await_suspend(std::coroutine_handle<> h, capy::await_context const* env) { parent_token_ = env->stop_token; @@ -164,7 +164,7 @@ struct timeout_awaitable // clear precondition diagnostic. This terminates by design // (a usage error) rather than dropping the requested timeout. // The detached timeout coroutine must own its executor by - // value (see timeout_coro::set_env_owned); io_env carries + // value (see timeout_coro::set_env_owned); await_context carries // only a non-owning executor_ref. Recover the concrete // executor from the context rather than the executor_ref: // wrapped executors (a strand over the io_context) satisfy diff --git a/include/boost/corosio/detail/timeout_coro.hpp b/include/boost/corosio/detail/timeout_coro.hpp index 1578d62fc..02248a5c1 100644 --- a/include/boost/corosio/detail/timeout_coro.hpp +++ b/include/boost/corosio/detail/timeout_coro.hpp @@ -11,10 +11,10 @@ #define BOOST_COROSIO_DETAIL_TIMEOUT_CORO_HPP #include -#include +#include #include -#include -#include +#include +#include #include #include @@ -24,7 +24,7 @@ /* Self-destroying coroutine that awaits a timer and signals a stop_source on expiry. Created suspended (initial_suspend = - suspend_always); the caller sets an owned io_env copy then + suspend_always); the caller sets an owned await_context copy then resumes, which runs synchronously until the timer wait suspends. At final_suspend, suspend_never destroys the frame — the timeout_coro destructor is intentionally a no-op since the @@ -33,8 +33,8 @@ completion_op::destroy(). The promise reuses task<>'s transform_awaiter pattern (including - the MSVC symmetric-transfer workaround) to inject io_env into - IoAwaitable co_await expressions. + the MSVC symmetric-transfer workaround) to inject await_context into + ContextAwaitable co_await expressions. The detached frame can outlive the awaiting chain, so it never allocates from that chain's frame allocator: timeout_awaitable @@ -52,10 +52,10 @@ namespace boost::corosio::detail { */ struct timeout_coro { - struct promise_type : capy::io_awaitable_promise_base + struct promise_type : capy::context_awaitable_promise_base { io_context::executor_type owned_ex_; - capy::io_env env_storage_; + capy::await_context env_storage_; /** Store an owned copy of the environment. @@ -132,14 +132,14 @@ struct timeout_coro auto transform_awaitable(Awaitable&& a) { using A = std::decay_t; - if constexpr (capy::IoAwaitable) + if constexpr (capy::ContextAwaitable) { return transform_awaiter{ std::forward(a), this}; } else { - static_assert(sizeof(A) == 0, "requires IoAwaitable"); + static_assert(sizeof(A) == 0, "requires ContextAwaitable"); } } }; diff --git a/include/boost/corosio/detail/timer.hpp b/include/boost/corosio/detail/timer.hpp index 36d11c0e1..9add53dba 100644 --- a/include/boost/corosio/detail/timer.hpp +++ b/include/boost/corosio/detail/timer.hpp @@ -16,11 +16,11 @@ #include #include #include -#include +#include #include #include #include -#include +#include #include #include @@ -318,7 +318,7 @@ class BOOST_COROSIO_DECL timer : public io_object This timer must outlive the returned awaitable. - @return An awaitable that completes with `io_result<>`. + @return An awaitable that completes with `results<>`. */ // Defined below wait_awaitable, which needs timer complete. wait_awaitable wait(); @@ -384,7 +384,7 @@ class BOOST_COROSIO_DECL timer : public io_object because either act may end the node's storage. The node owns no resources: the stop token is borrowed from the - awaiting chain's `io_env` (which outlives the suspension) and + awaiting chain's `await_context` (which outlives the suspension) and the stop callback is managed manually in `cb_buf_`, destroyed on every completion path before the frame can die. */ @@ -433,7 +433,7 @@ struct BOOST_COROSIO_SYMBOL_VISIBLE waiter_node /// The executor the continuation is posted through. capy::executor_ref d_; - // Borrowed from the awaiting chain's io_env, which outlives the + // Borrowed from the awaiting chain's await_context, which outlives the // suspension; the node holds no owning state. /// The stop token observed for cancellation. std::stop_token const* token_ = nullptr; @@ -485,7 +485,7 @@ struct BOOST_COROSIO_SYMBOL_VISIBLE waiter_node @param env The awaiting chain's environment; must outlive the suspension. */ - void bind(std::coroutine_handle<> h, capy::io_env const& env) noexcept + void bind(std::coroutine_handle<> h, capy::await_context const& env) noexcept { cont_.h = h; cont_.owner = env.owner; @@ -543,12 +543,12 @@ struct wait_awaitable // Cancellation surfaces through w_.ec_: the stop_token path in // wait() completes the waiter with error::canceled written to // it, so there is no separate token to consult here. - [[nodiscard]] capy::io_result<> await_resume() const noexcept + [[nodiscard]] capy::results<> await_resume() const noexcept { return {w_.ec_}; } - auto await_suspend(std::coroutine_handle<> h, capy::io_env const* env) + auto await_suspend(std::coroutine_handle<> h, capy::await_context const* env) -> std::coroutine_handle<> { auto& impl = t_.get(); diff --git a/include/boost/corosio/endpoint.hpp b/include/boost/corosio/endpoint.hpp index 243440a2a..41b145e01 100644 --- a/include/boost/corosio/endpoint.hpp +++ b/include/boost/corosio/endpoint.hpp @@ -15,7 +15,7 @@ #include #include -#include +#include #include #include @@ -213,7 +213,7 @@ endpoint_format detect_endpoint_format(std::string_view s) noexcept; @return The error code, empty on success, and the parsed endpoint — default-constructed on failure. */ -[[nodiscard]] BOOST_COROSIO_DECL capy::io_result +[[nodiscard]] BOOST_COROSIO_DECL capy::results make_endpoint(std::string_view s) noexcept; inline endpoint::endpoint(std::string_view s) diff --git a/include/boost/corosio/host_name.hpp b/include/boost/corosio/host_name.hpp index 42e8e3fc7..8b106993b 100644 --- a/include/boost/corosio/host_name.hpp +++ b/include/boost/corosio/host_name.hpp @@ -13,7 +13,7 @@ #include -#include +#include #include @@ -38,7 +38,7 @@ namespace boost::corosio { @return The error code, empty on success, and the hostname as a UTF-8 string — empty on failure. */ -[[nodiscard]] BOOST_COROSIO_DECL capy::io_result host_name(); +[[nodiscard]] BOOST_COROSIO_DECL capy::results host_name(); } // namespace boost::corosio diff --git a/include/boost/corosio/io/io_read_stream.hpp b/include/boost/corosio/io/io_read_stream.hpp index 838646b90..f27e059ee 100644 --- a/include/boost/corosio/io/io_read_stream.hpp +++ b/include/boost/corosio/io/io_read_stream.hpp @@ -14,9 +14,9 @@ #include #include #include -#include +#include #include -#include +#include #include diff --git a/include/boost/corosio/io/io_signal_set.hpp b/include/boost/corosio/io/io_signal_set.hpp index 293db87cd..24209d704 100644 --- a/include/boost/corosio/io/io_signal_set.hpp +++ b/include/boost/corosio/io/io_signal_set.hpp @@ -13,10 +13,10 @@ #include #include #include -#include +#include #include #include -#include +#include #include @@ -117,7 +117,7 @@ class BOOST_COROSIO_DECL io_signal_set : public io_object inline, on the thread that called `request_stop()`. On POSIX it always resumes on a thread running the execution context. - @return An awaitable that completes with `io_result`. + @return An awaitable that completes with `results`. Returns the signal number when a signal is delivered, or an error code on failure. */ diff --git a/include/boost/corosio/io/io_write_stream.hpp b/include/boost/corosio/io/io_write_stream.hpp index c9b0163f7..bd2055d97 100644 --- a/include/boost/corosio/io/io_write_stream.hpp +++ b/include/boost/corosio/io/io_write_stream.hpp @@ -14,9 +14,9 @@ #include #include #include -#include +#include #include -#include +#include #include diff --git a/include/boost/corosio/ip_address.hpp b/include/boost/corosio/ip_address.hpp index 59c9fcc88..1727737b3 100644 --- a/include/boost/corosio/ip_address.hpp +++ b/include/boost/corosio/ip_address.hpp @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include @@ -326,7 +326,7 @@ class BOOST_COROSIO_DECL ip_address @return The error code, empty on success, and the parsed address — default-constructed on failure. */ -[[nodiscard]] BOOST_COROSIO_DECL capy::io_result +[[nodiscard]] BOOST_COROSIO_DECL capy::results make_ip_address(std::string_view s) noexcept; inline ip_address::ip_address(std::string_view s) diff --git a/include/boost/corosio/ipv4_address.hpp b/include/boost/corosio/ipv4_address.hpp index 33b204e23..202e7329e 100644 --- a/include/boost/corosio/ipv4_address.hpp +++ b/include/boost/corosio/ipv4_address.hpp @@ -13,7 +13,7 @@ #include -#include +#include #include #include @@ -264,7 +264,7 @@ class BOOST_COROSIO_DECL ipv4_address @return The error code, empty on success, and the parsed address — default-constructed on failure. */ -[[nodiscard]] BOOST_COROSIO_DECL capy::io_result +[[nodiscard]] BOOST_COROSIO_DECL capy::results make_ipv4_address(std::string_view s) noexcept; } // namespace boost::corosio diff --git a/include/boost/corosio/ipv6_address.hpp b/include/boost/corosio/ipv6_address.hpp index 7dcd663e1..b0258bfc8 100644 --- a/include/boost/corosio/ipv6_address.hpp +++ b/include/boost/corosio/ipv6_address.hpp @@ -14,7 +14,7 @@ #include #include -#include +#include #include #include @@ -392,7 +392,7 @@ class BOOST_COROSIO_DECL ipv6_address @return The error code, empty on success, and the parsed address — default-constructed on failure. */ -[[nodiscard]] BOOST_COROSIO_DECL capy::io_result +[[nodiscard]] BOOST_COROSIO_DECL capy::results make_ipv6_address(std::string_view s) noexcept; } // namespace boost::corosio diff --git a/include/boost/corosio/local_datagram_socket.hpp b/include/boost/corosio/local_datagram_socket.hpp index f97370e9e..91d36ac58 100644 --- a/include/boost/corosio/local_datagram_socket.hpp +++ b/include/boost/corosio/local_datagram_socket.hpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include @@ -629,7 +629,7 @@ class BOOST_COROSIO_DECL local_datagram_socket : public io_object calling cancel(). On cancellation, yields `capy::cond::canceled`. - @return An awaitable that completes with io_result<>. + @return An awaitable that completes with `results<>`. If the socket needs to be opened and the open fails, the awaitable completes immediately with that error. @@ -650,7 +650,7 @@ class BOOST_COROSIO_DECL local_datagram_socket : public io_object @param w The wait direction (read, write, or error). - @return An awaitable that completes with `io_result<>`. + @return An awaitable that completes with `results<>`. A closed socket completes with `errc::bad_file_descriptor`. @@ -675,7 +675,7 @@ class BOOST_COROSIO_DECL local_datagram_socket : public io_object Supports cancellation via stop_token or cancel(). @return An awaitable that completes with - io_result. + results. A closed socket reports `errc::bad_file_descriptor`. */ @@ -715,7 +715,7 @@ class BOOST_COROSIO_DECL local_datagram_socket : public io_object Supports cancellation via stop_token or cancel(). @return An awaitable that completes with - io_result. + results. A closed socket reports `errc::bad_file_descriptor`. */ @@ -750,7 +750,7 @@ class BOOST_COROSIO_DECL local_datagram_socket : public io_object Supports cancellation via stop_token or cancel(). @return An awaitable that completes with - io_result. + results. A closed socket reports `errc::bad_file_descriptor`. */ @@ -781,7 +781,7 @@ class BOOST_COROSIO_DECL local_datagram_socket : public io_object Supports cancellation via stop_token or cancel(). @return An awaitable that completes with - io_result. + results. A closed socket reports `errc::bad_file_descriptor`. */ diff --git a/include/boost/corosio/local_stream_acceptor.hpp b/include/boost/corosio/local_stream_acceptor.hpp index c014c9cc5..9ffd534a1 100644 --- a/include/boost/corosio/local_stream_acceptor.hpp +++ b/include/boost/corosio/local_stream_acceptor.hpp @@ -17,12 +17,12 @@ #include #include #include -#include +#include #include #include #include #include -#include +#include #include #include @@ -126,7 +126,7 @@ class BOOST_COROSIO_DECL local_stream_acceptor : public io_object discard_peer(acc_, peer_impl_); } - [[nodiscard]] capy::io_result + [[nodiscard]] capy::results await_resume() const noexcept { if (this->ec_ || !peer_impl_) @@ -172,7 +172,7 @@ class BOOST_COROSIO_DECL local_stream_acceptor : public io_object discard_peer(acc_, peer_impl_); } - [[nodiscard]] capy::io_result<> await_resume() const noexcept + [[nodiscard]] capy::results<> await_resume() const noexcept { if (!this->ec_ && peer_impl_) peer_.h_.reset(std::exchange(peer_impl_, nullptr)); @@ -356,7 +356,7 @@ class BOOST_COROSIO_DECL local_stream_acceptor : public io_object On cancellation, yields `capy::cond::canceled` and @p peer is not modified. - @return An awaitable that completes with io_result<>. + @return An awaitable that completes with `results<>`. A closed acceptor reports `errc::bad_file_descriptor`. */ @@ -384,7 +384,7 @@ class BOOST_COROSIO_DECL local_stream_acceptor : public io_object @param w The wait direction. - @return An awaitable that completes with `io_result<>`. + @return An awaitable that completes with `results<>`. A closed acceptor completes with `errc::bad_file_descriptor`. @@ -409,7 +409,7 @@ class BOOST_COROSIO_DECL local_stream_acceptor : public io_object a default-constructed socket. @return An awaitable that completes with - io_result<`local_stream_socket`>. + results<`local_stream_socket`>. A closed acceptor reports `errc::bad_file_descriptor`. On failure the returned socket is default-constructed and diff --git a/include/boost/corosio/local_stream_socket.hpp b/include/boost/corosio/local_stream_socket.hpp index 44bf2d3ce..c2aca8d0d 100644 --- a/include/boost/corosio/local_stream_socket.hpp +++ b/include/boost/corosio/local_stream_socket.hpp @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include #include @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include @@ -357,7 +357,7 @@ class BOOST_COROSIO_DECL local_stream_socket : public io_stream @param ep The local endpoint (path) to connect to. - @return An awaitable that completes with io_result<>. + @return An awaitable that completes with `results<>`. If the socket needs to be opened and the open fails, the awaitable completes immediately with that error. @@ -378,7 +378,7 @@ class BOOST_COROSIO_DECL local_stream_socket : public io_stream @param w The wait direction (read, write, or error). - @return An awaitable that completes with `io_result<>`. + @return An awaitable that completes with `results<>`. A closed socket completes with `errc::bad_file_descriptor`. diff --git a/include/boost/corosio/native/detail/coro_op_complete.hpp b/include/boost/corosio/native/detail/coro_op_complete.hpp index 37cff08fa..9c71f3847 100644 --- a/include/boost/corosio/native/detail/coro_op_complete.hpp +++ b/include/boost/corosio/native/detail/coro_op_complete.hpp @@ -80,7 +80,7 @@ namespace boost::corosio::detail { which suppresses the otherwise-spurious EOF. */ inline void -decode_io_result( +decode_results( std::error_code* ec_out, std::size_t* bytes_out, bool cancelled, diff --git a/include/boost/corosio/native/detail/iocp/win_file_service.hpp b/include/boost/corosio/native/detail/iocp/win_file_service.hpp index b973f1c12..25dc66f8a 100644 --- a/include/boost/corosio/native/detail/iocp/win_file_service.hpp +++ b/include/boost/corosio/native/detail/iocp/win_file_service.hpp @@ -153,7 +153,7 @@ win_stream_file_internal::sync_all() noexcept return {}; } -inline capy::io_result +inline capy::results win_stream_file_internal::seek( std::int64_t offset, file_base::seek_basis origin) noexcept { @@ -280,7 +280,7 @@ win_stream_file::assign(native_handle_type handle) noexcept return internal_.assign(handle, handle_kind::stream_file); } -inline capy::io_result +inline capy::results win_stream_file::seek( std::int64_t offset, file_base::seek_basis origin) noexcept { diff --git a/include/boost/corosio/native/detail/iocp/win_overlapped_handle.hpp b/include/boost/corosio/native/detail/iocp/win_overlapped_handle.hpp index ea454c625..70040fcc8 100644 --- a/include/boost/corosio/native/detail/iocp/win_overlapped_handle.hpp +++ b/include/boost/corosio/native/detail/iocp/win_overlapped_handle.hpp @@ -57,7 +57,7 @@ namespace boost::corosio::detail { -/** Map a handle completion code to what decode_io_result expects. +/** Map a handle completion code to what decode_results expects. On reads, end of data (`ERROR_HANDLE_EOF`, `ERROR_BROKEN_PIPE` once a pipe's writer is gone, or `ERROR_PIPE_NOT_CONNECTED` after @@ -503,7 +503,7 @@ class win_concurrent_handle : public win_handle_base } DWORD const err = normalize_handle_error(op->dwError, op->is_read); - decode_io_result( + decode_results( op->ec_out, op->bytes_out, op->cancelled.load(std::memory_order_acquire), err != 0 ? iocp_make_err(err, /*accept_path=*/false) diff --git a/include/boost/corosio/native/detail/iocp/win_overlapped_op.hpp b/include/boost/corosio/native/detail/iocp/win_overlapped_op.hpp index 1629c92b4..cb225a6a5 100644 --- a/include/boost/corosio/native/detail/iocp/win_overlapped_op.hpp +++ b/include/boost/corosio/native/detail/iocp/win_overlapped_op.hpp @@ -230,7 +230,7 @@ struct overlapped_op { stop_cb.reset(); - decode_io_result( + decode_results( ec_out, bytes_out, cancelled.load(std::memory_order_acquire), dwError != 0 ? iocp_make_err(dwError, /*accept_path=*/false) : std::error_code{}, diff --git a/include/boost/corosio/native/detail/iocp/win_stream_file.hpp b/include/boost/corosio/native/detail/iocp/win_stream_file.hpp index 31db3ef6f..3c8ba0417 100644 --- a/include/boost/corosio/native/detail/iocp/win_stream_file.hpp +++ b/include/boost/corosio/native/detail/iocp/win_stream_file.hpp @@ -50,7 +50,7 @@ class win_stream_file_internal : public win_slot_handle std::error_code resize(std::uint64_t new_size) noexcept; std::error_code sync_data() noexcept; std::error_code sync_all() noexcept; - capy::io_result + capy::results seek(std::int64_t offset, file_base::seek_basis origin) noexcept; private: @@ -107,7 +107,7 @@ class win_stream_file final std::error_code sync_all() noexcept override; native_handle_type release() override; std::error_code assign(native_handle_type handle) noexcept override; - capy::io_result + capy::results seek(std::int64_t offset, file_base::seek_basis origin) noexcept override; win_stream_file_internal* get_internal() noexcept; diff --git a/include/boost/corosio/native/detail/posix/posix_random_access_file.hpp b/include/boost/corosio/native/detail/posix/posix_random_access_file.hpp index 23721f381..2a6628aea 100644 --- a/include/boost/corosio/native/detail/posix/posix_random_access_file.hpp +++ b/include/boost/corosio/native/detail/posix/posix_random_access_file.hpp @@ -360,7 +360,7 @@ posix_random_access_file::raf_op::operator()() // Empty buffers never reach the pool (diverted at initiation), so // empty_buffer stays false and a 0-byte read is a genuine EOF. - decode_io_result( + decode_results( ec_out, bytes_out, cancelled.load(std::memory_order_acquire), errn != 0 ? make_err(errn) : std::error_code{}, is_read, bytes_transferred, /*empty_buffer=*/false); diff --git a/include/boost/corosio/native/detail/posix/posix_stream_file.hpp b/include/boost/corosio/native/detail/posix/posix_stream_file.hpp index 7f8e1c60b..5e119be1b 100644 --- a/include/boost/corosio/native/detail/posix/posix_stream_file.hpp +++ b/include/boost/corosio/native/detail/posix/posix_stream_file.hpp @@ -212,7 +212,7 @@ class posix_stream_file final std::error_code sync_all() noexcept override; native_handle_type release() override; std::error_code assign(native_handle_type handle) noexcept override; - capy::io_result + capy::results seek(std::int64_t offset, file_base::seek_basis origin) noexcept override; // -- Internal -- @@ -391,7 +391,7 @@ posix_stream_file::release() return fd; } -inline capy::io_result +inline capy::results posix_stream_file::seek( std::int64_t offset, file_base::seek_basis origin) noexcept { @@ -437,7 +437,7 @@ posix_stream_file::file_op::operator()() // Empty buffers never reach the pool (diverted at initiation), so // empty_buffer stays false and a 0-byte read is a genuine EOF. - decode_io_result( + decode_results( ec_out, bytes_out, cancelled.load(std::memory_order_acquire), errn != 0 ? make_err(errn) : std::error_code{}, is_read, bytes_transferred, /*empty_buffer=*/false); diff --git a/include/boost/corosio/native/detail/reactor/reactor_op_complete.hpp b/include/boost/corosio/native/detail/reactor/reactor_op_complete.hpp index fec3a6f6f..b748382b7 100644 --- a/include/boost/corosio/native/detail/reactor/reactor_op_complete.hpp +++ b/include/boost/corosio/native/detail/reactor/reactor_op_complete.hpp @@ -50,7 +50,7 @@ complete_io_op(Op& op) // returns false for a zero-length read), so empty_buffer stays false // here and the shared EOF test reduces to the reactor's original // `is_read && bytes == 0`. - decode_io_result( + decode_results( op.ec_out, op.bytes_out, op.cancelled.load(std::memory_order_acquire), op.errn != 0 ? make_err(op.errn) : std::error_code{}, op.is_read_operation(), op.bytes_transferred, /*empty_buffer=*/false); @@ -86,7 +86,7 @@ complete_wait_op(Op& op) } // Wait reports only success/cancel/error — no bytes, no EOF. - decode_io_result( + decode_results( op.ec_out, /*bytes_out=*/nullptr, op.cancelled.load(std::memory_order_acquire), op.errn != 0 ? make_err(op.errn) : std::error_code{}, @@ -127,7 +127,7 @@ complete_connect_op(Op& op) op.socket_impl_->set_endpoints(local_ep, op.target_endpoint); } - decode_io_result( + decode_results( op.ec_out, /*bytes_out=*/nullptr, op.cancelled.load(std::memory_order_acquire), op.errn != 0 ? make_err(op.errn) : std::error_code{}, @@ -221,7 +221,7 @@ complete_accept_op(Op& op) bool success = (op.errn == 0 && !op.cancelled.load(std::memory_order_acquire)); - decode_io_result( + decode_results( op.ec_out, /*bytes_out=*/nullptr, op.cancelled.load(std::memory_order_acquire), op.errn != 0 ? make_err(op.errn) : std::error_code{}, @@ -266,7 +266,7 @@ complete_datagram_op(Op& op) op.socket_impl_->desc_state_.scheduler_->reset_inline_budget(); // No EOF: a zero-length datagram is valid (success with 0 bytes). - decode_io_result( + decode_results( op.ec_out, op.bytes_out, op.cancelled.load(std::memory_order_acquire), op.errn != 0 ? make_err(op.errn) : std::error_code{}, /*is_read=*/false, op.bytes_transferred, /*empty_buffer=*/false); @@ -293,7 +293,7 @@ complete_datagram_op(Op& op, Endpoint* source_out) op.socket_impl_->desc_state_.scheduler_->reset_inline_budget(); // No EOF: a zero-length datagram is valid (success with 0 bytes). - decode_io_result( + decode_results( op.ec_out, op.bytes_out, op.cancelled.load(std::memory_order_acquire), op.errn != 0 ? make_err(op.errn) : std::error_code{}, /*is_read=*/false, op.bytes_transferred, /*empty_buffer=*/false); diff --git a/include/boost/corosio/native/detail/uring/uring_dgram_ops.hpp b/include/boost/corosio/native/detail/uring/uring_dgram_ops.hpp index 1736a62ba..91531049b 100644 --- a/include/boost/corosio/native/detail/uring/uring_dgram_ops.hpp +++ b/include/boost/corosio/native/detail/uring/uring_dgram_ops.hpp @@ -138,7 +138,7 @@ struct uring_dgram_send_op : uring_op self->sched_->reset_inline_budget(); // Datagram send: no EOF (a 0-byte send is success). - decode_io_result( + decode_results( self->ec_out, self->bytes_out, self->cancelled.load(std::memory_order_acquire), self->res < 0 ? make_err(-self->res) : std::error_code{}, @@ -293,7 +293,7 @@ struct uring_dgram_recv_op : uring_op // Datagram recv: a 0-byte datagram is success, not EOF — is_read // stays false so the shared decode never maps it to end_of_file. - decode_io_result( + decode_results( self->ec_out, self->bytes_out, self->cancelled.load(std::memory_order_acquire), self->res < 0 ? make_err(-self->res) : std::error_code{}, diff --git a/include/boost/corosio/native/detail/uring/uring_socket_ops.hpp b/include/boost/corosio/native/detail/uring/uring_socket_ops.hpp index e4e1070ab..9e73e7661 100644 --- a/include/boost/corosio/native/detail/uring/uring_socket_ops.hpp +++ b/include/boost/corosio/native/detail/uring/uring_socket_ops.hpp @@ -89,7 +89,7 @@ copy_to_iovec( inline void uring_set_result(uring_op* self, bool is_read, bool empty_buf) noexcept { - decode_io_result( + decode_results( self->ec_out, self->bytes_out, self->cancelled.load(std::memory_order_acquire), self->res < 0 ? make_err(-self->res) : std::error_code{}, is_read, @@ -673,7 +673,7 @@ struct uring_wait_op : uring_op } // Wait reports only success/cancel/error — no bytes, no EOF. - decode_io_result( + decode_results( self->ec_out, /*bytes_out=*/nullptr, self->cancelled.load(std::memory_order_acquire), ec, /*is_read=*/false, /*bytes=*/0, /*empty_buffer=*/false); diff --git a/include/boost/corosio/native/detail/uring/uring_stream_file.hpp b/include/boost/corosio/native/detail/uring/uring_stream_file.hpp index ea516a388..0eb2ed261 100644 --- a/include/boost/corosio/native/detail/uring/uring_stream_file.hpp +++ b/include/boost/corosio/native/detail/uring/uring_stream_file.hpp @@ -200,7 +200,7 @@ class BOOST_COROSIO_DECL uring_stream_file final return {}; } - capy::io_result + capy::results seek(std::int64_t offset, file_base::seek_basis origin) noexcept override { int whence = SEEK_SET; diff --git a/include/boost/corosio/native/detail/uring/uring_types.hpp b/include/boost/corosio/native/detail/uring/uring_types.hpp index c5045879f..a77a1e5a8 100644 --- a/include/boost/corosio/native/detail/uring/uring_types.hpp +++ b/include/boost/corosio/native/detail/uring/uring_types.hpp @@ -200,7 +200,7 @@ class BOOST_COROSIO_DECL uring_tcp_socket final { if (sched_->try_consume_inline_budget()) { - decode_io_result( + decode_results( ec, bytes, stop_now, err ? make_err(err) : std::error_code{}, /*is_read=*/true, n < 0 ? 0u : static_cast(n), @@ -278,7 +278,7 @@ class BOOST_COROSIO_DECL uring_tcp_socket final { if (sched_->try_consume_inline_budget()) { - decode_io_result( + decode_results( ec, bytes, stop_now, err ? make_err(err) : std::error_code{}, /*is_read=*/false, n < 0 ? 0u : static_cast(n), @@ -1171,7 +1171,7 @@ class BOOST_COROSIO_DECL uring_local_stream_socket final { if (sched_->try_consume_inline_budget()) { - decode_io_result( + decode_results( ec, bytes, stop_now, err ? make_err(err) : std::error_code{}, /*is_read=*/true, n < 0 ? 0u : static_cast(n), @@ -1249,7 +1249,7 @@ class BOOST_COROSIO_DECL uring_local_stream_socket final { if (sched_->try_consume_inline_budget()) { - decode_io_result( + decode_results( ec, bytes, stop_now, err ? make_err(err) : std::error_code{}, /*is_read=*/false, n < 0 ? 0u : static_cast(n), @@ -2277,7 +2277,7 @@ class BOOST_COROSIO_DECL uring_udp_socket final { if (sched_->try_consume_inline_budget()) { - decode_io_result( + decode_results( ec, bytes, stop_now, err ? make_err(err) : std::error_code{}, /*is_read=*/false, n < 0 ? 0u : static_cast(n), @@ -2368,7 +2368,7 @@ class BOOST_COROSIO_DECL uring_udp_socket final { if (sched_->try_consume_inline_budget()) { - decode_io_result( + decode_results( ec, bytes, stop_now, err ? make_err(err) : std::error_code{}, /*is_read=*/false, n < 0 ? 0u : static_cast(n), @@ -2938,7 +2938,7 @@ class BOOST_COROSIO_DECL uring_local_datagram_socket final { if (sched_->try_consume_inline_budget()) { - decode_io_result( + decode_results( ec, bytes, stop_now, err ? make_err(err) : std::error_code{}, /*is_read=*/false, n < 0 ? 0u : static_cast(n), @@ -3029,7 +3029,7 @@ class BOOST_COROSIO_DECL uring_local_datagram_socket final { if (sched_->try_consume_inline_budget()) { - decode_io_result( + decode_results( ec, bytes, stop_now, err ? make_err(err) : std::error_code{}, /*is_read=*/false, n < 0 ? 0u : static_cast(n), diff --git a/include/boost/corosio/native/native_local_datagram_socket.hpp b/include/boost/corosio/native/native_local_datagram_socket.hpp index a62d456d8..e6b76e73d 100644 --- a/include/boost/corosio/native/native_local_datagram_socket.hpp +++ b/include/boost/corosio/native/native_local_datagram_socket.hpp @@ -415,7 +415,7 @@ class native_local_datagram_socket : public local_datagram_socket @param w The wait direction (read, write, or error). - @return An awaitable yielding `io_result<>`. + @return An awaitable yielding `results<>`. */ [[nodiscard]] auto wait(wait_type w) { diff --git a/include/boost/corosio/native/native_local_stream_acceptor.hpp b/include/boost/corosio/native/native_local_stream_acceptor.hpp index f6213ba2e..7d5d2d6c7 100644 --- a/include/boost/corosio/native/native_local_stream_acceptor.hpp +++ b/include/boost/corosio/native/native_local_stream_acceptor.hpp @@ -110,7 +110,7 @@ class native_local_stream_acceptor : public local_stream_acceptor { } - [[nodiscard]] capy::io_result<> await_resume() const noexcept + [[nodiscard]] capy::results<> await_resume() const noexcept { if (!this->ec_) acc_.reset_peer_impl(peer_, peer_impl_); @@ -137,7 +137,7 @@ class native_local_stream_acceptor : public local_stream_acceptor { } - [[nodiscard]] capy::io_result> + [[nodiscard]] capy::results> await_resume() const noexcept { if (this->ec_ || !peer_impl_) @@ -203,7 +203,7 @@ class native_local_stream_acceptor : public local_stream_acceptor @param peer The socket to receive the accepted connection. - @return An awaitable yielding `io_result<>`. + @return An awaitable yielding `results<>`. A closed acceptor reports `errc::bad_file_descriptor`. @@ -226,7 +226,7 @@ class native_local_stream_acceptor : public local_stream_acceptor is also devirtualized. @return An awaitable yielding - `io_result>`. + `results>`. A closed acceptor reports `errc::bad_file_descriptor`. @@ -253,7 +253,7 @@ class native_local_stream_acceptor : public local_stream_acceptor @param w The wait direction (typically `wait_type::read`). - @return An awaitable yielding `io_result<>`. + @return An awaitable yielding `results<>`. */ [[nodiscard]] auto wait(wait_type w) { diff --git a/include/boost/corosio/native/native_local_stream_socket.hpp b/include/boost/corosio/native/native_local_stream_socket.hpp index b2449618e..3d71f5dd1 100644 --- a/include/boost/corosio/native/native_local_stream_socket.hpp +++ b/include/boost/corosio/native/native_local_stream_socket.hpp @@ -241,7 +241,7 @@ class native_local_stream_socket : public local_stream_socket @param ep The local endpoint (path) to connect to. - @return An awaitable yielding `io_result<>`. + @return An awaitable yielding `results<>`. If the socket needs to be opened and the open fails, the awaitable completes immediately with that error. @@ -261,7 +261,7 @@ class native_local_stream_socket : public local_stream_socket @param w The wait direction (read, write, or error). - @return An awaitable yielding `io_result<>`. + @return An awaitable yielding `results<>`. */ [[nodiscard]] auto wait(wait_type w) { diff --git a/include/boost/corosio/native/native_posix_stream_descriptor.hpp b/include/boost/corosio/native/native_posix_stream_descriptor.hpp index 32cabff8a..77a013730 100644 --- a/include/boost/corosio/native/native_posix_stream_descriptor.hpp +++ b/include/boost/corosio/native/native_posix_stream_descriptor.hpp @@ -236,7 +236,7 @@ class native_posix_stream_descriptor : public posix_stream_descriptor @param w The direction to wait on. - @return An awaitable yielding `io_result<>`. + @return An awaitable yielding `results<>`. */ [[nodiscard]] auto wait(wait_type w) { diff --git a/include/boost/corosio/native/native_resolver.hpp b/include/boost/corosio/native/native_resolver.hpp index 59a76a567..8a15ab046 100644 --- a/include/boost/corosio/native/native_resolver.hpp +++ b/include/boost/corosio/native/native_resolver.hpp @@ -166,7 +166,7 @@ class native_resolver : public resolver @param host The host name or address string. @param service The service name or port string. - @return An awaitable yielding `io_result>`. + @return An awaitable yielding `results>`. */ [[nodiscard]] auto resolve(std::string_view host, std::string_view service) { @@ -183,7 +183,7 @@ class native_resolver : public resolver @param flags Flags controlling resolution behavior. @return An awaitable yielding - `io_result>`. + `results>`. */ [[nodiscard]] auto resolve( std::string_view host, std::string_view service, resolve_flags flags) @@ -202,7 +202,7 @@ class native_resolver : public resolver @param ep The endpoint to resolve. @return An awaitable yielding - `io_result`. + `results`. */ [[nodiscard]] auto resolve(endpoint const& ep) { @@ -217,7 +217,7 @@ class native_resolver : public resolver @param flags Flags controlling resolution behavior. @return An awaitable yielding - `io_result`. + `results`. */ [[nodiscard]] auto resolve(endpoint const& ep, reverse_flags flags) { diff --git a/include/boost/corosio/native/native_signal_set.hpp b/include/boost/corosio/native/native_signal_set.hpp index f6b956ff3..92b36fde1 100644 --- a/include/boost/corosio/native/native_signal_set.hpp +++ b/include/boost/corosio/native/native_signal_set.hpp @@ -130,7 +130,7 @@ class native_signal_set : public signal_set Calls the backend implementation directly, bypassing virtual dispatch. Otherwise identical to @ref signal_set::wait. - @return An awaitable yielding `io_result`. + @return An awaitable yielding `results`. This signal set must outlive the returned awaitable. */ diff --git a/include/boost/corosio/native/native_tcp_acceptor.hpp b/include/boost/corosio/native/native_tcp_acceptor.hpp index bb9e06334..15d115e39 100644 --- a/include/boost/corosio/native/native_tcp_acceptor.hpp +++ b/include/boost/corosio/native/native_tcp_acceptor.hpp @@ -102,7 +102,7 @@ class native_tcp_acceptor : public tcp_acceptor { } - [[nodiscard]] capy::io_result<> await_resume() const noexcept + [[nodiscard]] capy::results<> await_resume() const noexcept { if (!this->ec_) acc_.reset_peer_impl(peer_, peer_impl_); @@ -130,7 +130,7 @@ class native_tcp_acceptor : public tcp_acceptor { } - [[nodiscard]] capy::io_result await_resume() noexcept + [[nodiscard]] capy::results await_resume() noexcept { if (!this->ec_ && peer_impl_) acc_.reset_peer_impl(peer_, peer_impl_); @@ -204,7 +204,7 @@ class native_tcp_acceptor : public tcp_acceptor @param peer The socket to receive the accepted connection. - @return An awaitable yielding `io_result<>`. + @return An awaitable yielding `results<>`. A closed acceptor reports `errc::bad_file_descriptor`. @@ -224,7 +224,7 @@ class native_tcp_acceptor : public tcp_acceptor Calls the backend implementation directly, bypassing virtual dispatch. Otherwise identical to @ref tcp_acceptor::accept(). - @return An awaitable yielding `io_result`. + @return An awaitable yielding `results`. A closed acceptor reports `errc::bad_file_descriptor`. @@ -251,7 +251,7 @@ class native_tcp_acceptor : public tcp_acceptor @param w The wait direction (typically `wait_type::read`). - @return An awaitable yielding `io_result<>`. + @return An awaitable yielding `results<>`. */ [[nodiscard]] auto wait(wait_type w) { diff --git a/include/boost/corosio/native/native_tcp_socket.hpp b/include/boost/corosio/native/native_tcp_socket.hpp index 9dce5d4f3..06b8386e5 100644 --- a/include/boost/corosio/native/native_tcp_socket.hpp +++ b/include/boost/corosio/native/native_tcp_socket.hpp @@ -264,7 +264,7 @@ class native_tcp_socket : public tcp_socket @param ep The remote endpoint to connect to. - @return An awaitable yielding `io_result<>`. + @return An awaitable yielding `results<>`. This socket must outlive the returned awaitable. */ @@ -283,7 +283,7 @@ class native_tcp_socket : public tcp_socket @param w The wait direction (read, write, or error). - @return An awaitable yielding `io_result<>`. + @return An awaitable yielding `results<>`. */ [[nodiscard]] auto wait(wait_type w) { diff --git a/include/boost/corosio/native/native_udp_socket.hpp b/include/boost/corosio/native/native_udp_socket.hpp index 0cf16248e..aeea89d50 100644 --- a/include/boost/corosio/native/native_udp_socket.hpp +++ b/include/boost/corosio/native/native_udp_socket.hpp @@ -355,7 +355,7 @@ class native_udp_socket : public udp_socket @param ep The remote endpoint to connect to. - @return An awaitable yielding `io_result<>`. + @return An awaitable yielding `results<>`. If the socket needs to be opened and the open fails, the awaitable completes immediately with that error. @@ -431,7 +431,7 @@ class native_udp_socket : public udp_socket @param w The wait direction (read, write, or error). - @return An awaitable yielding `io_result<>`. + @return An awaitable yielding `results<>`. */ [[nodiscard]] auto wait(wait_type w) { diff --git a/include/boost/corosio/native/native_win_object_handle.hpp b/include/boost/corosio/native/native_win_object_handle.hpp index 2003d6b72..62583390a 100644 --- a/include/boost/corosio/native/native_win_object_handle.hpp +++ b/include/boost/corosio/native/native_win_object_handle.hpp @@ -131,7 +131,7 @@ class native_win_object_handle : public win_object_handle Calls the backend implementation directly, bypassing virtual dispatch. Otherwise identical to @ref win_object_handle::wait. - @return An awaitable yielding `io_result<>`. + @return An awaitable yielding `results<>`. */ [[nodiscard]] auto wait() { diff --git a/include/boost/corosio/openssl_stream.hpp b/include/boost/corosio/openssl_stream.hpp index ebd56bd62..b7f174990 100644 --- a/include/boost/corosio/openssl_stream.hpp +++ b/include/boost/corosio/openssl_stream.hpp @@ -18,7 +18,8 @@ #include #include #include -#include +#include +#include #include #include @@ -149,7 +150,7 @@ class BOOST_COROSIO_DECL openssl_stream final : public tls_stream @return An awaitable yielding `(error_code)`. */ - [[nodiscard]] capy::io_task<> handshake(tls_role role) override; + [[nodiscard]] capy::task> handshake(tls_role role) override; /** Asynchronously shut down the TLS session. @@ -170,7 +171,7 @@ class BOOST_COROSIO_DECL openssl_stream final : public tls_stream @return An awaitable yielding `(error_code)`. */ - [[nodiscard]] capy::io_task<> shutdown() override; + [[nodiscard]] capy::task> shutdown() override; /// Cancel operations pending on the owned underlying stream. void cancel() noexcept override; @@ -212,12 +213,12 @@ class BOOST_COROSIO_DECL openssl_stream final : public tls_stream protected: /// @copydoc tls_stream::do_read_some - capy::io_task do_read_some( + capy::task> do_read_some( capy::detail::mutable_buffer_array buffers) override; /// @copydoc tls_stream::do_write_some - capy::io_task do_write_some( + capy::task> do_write_some( capy::detail::const_buffer_array buffers) override; diff --git a/include/boost/corosio/posix_stream_descriptor.hpp b/include/boost/corosio/posix_stream_descriptor.hpp index 6234167ff..f467a547b 100644 --- a/include/boost/corosio/posix_stream_descriptor.hpp +++ b/include/boost/corosio/posix_stream_descriptor.hpp @@ -347,7 +347,7 @@ class BOOST_COROSIO_DECL posix_stream_descriptor : public io_stream @param w The direction to wait on. - @return An awaitable yielding `capy::io_result<>`. Yields + @return An awaitable yielding `capy::results<>`. Yields `errc::bad_file_descriptor` when not open. @par Example diff --git a/include/boost/corosio/random_access_file.hpp b/include/boost/corosio/random_access_file.hpp index 2c7d8ada9..ecdf2cb65 100644 --- a/include/boost/corosio/random_access_file.hpp +++ b/include/boost/corosio/random_access_file.hpp @@ -20,10 +20,10 @@ #include #include #include -#include +#include #include #include -#include +#include #include #include diff --git a/include/boost/corosio/resolver.hpp b/include/boost/corosio/resolver.hpp index be1af9d32..5e639316e 100644 --- a/include/boost/corosio/resolver.hpp +++ b/include/boost/corosio/resolver.hpp @@ -16,10 +16,10 @@ #include #include #include -#include +#include #include #include -#include +#include #include #include @@ -258,7 +258,7 @@ class BOOST_COROSIO_DECL resolver : public io_object public: // Shadows the base: the endpoint result is reshaped into // the honest address list - [[nodiscard]] capy::io_result> + [[nodiscard]] capy::results> await_resume() const { std::vector addrs; @@ -395,7 +395,7 @@ class BOOST_COROSIO_DECL resolver : public io_object port number. @return An awaitable that completes with - `io_result>`. + `results>`. @par Example @par !example forward_resolve @@ -419,7 +419,7 @@ class BOOST_COROSIO_DECL resolver : public io_object @param host The host name or numeric address string. @return An awaitable that completes with - `io_result>`. + `results>`. @par Example @par !example host_only_resolve @@ -435,7 +435,7 @@ class BOOST_COROSIO_DECL resolver : public io_object @param flags Resolution behavior flags. @return An awaitable that completes with - `io_result>`. + `results>`. */ [[nodiscard]] auto resolve(std::string_view host, resolve_flags flags) { @@ -455,7 +455,7 @@ class BOOST_COROSIO_DECL resolver : public io_object @param flags Flags controlling resolution behavior. @return An awaitable that completes with - `io_result>`. + `results>`. */ [[nodiscard]] auto resolve( std::string_view host, std::string_view service, resolve_flags flags) @@ -473,7 +473,7 @@ class BOOST_COROSIO_DECL resolver : public io_object @param ep The endpoint to resolve. @return An awaitable that completes with - `io_result`. + `results`. @par Example @par !example reverse_resolve @@ -495,7 +495,7 @@ class BOOST_COROSIO_DECL resolver : public io_object @param flags Flags controlling resolution behavior. See reverse_flags. @return An awaitable that completes with - `io_result`. + `results`. */ [[nodiscard]] auto resolve(endpoint const& ep, reverse_flags flags) { diff --git a/include/boost/corosio/stream_file.hpp b/include/boost/corosio/stream_file.hpp index 23faddce5..a113b9b56 100644 --- a/include/boost/corosio/stream_file.hpp +++ b/include/boost/corosio/stream_file.hpp @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include @@ -125,7 +125,7 @@ class BOOST_COROSIO_DECL stream_file : public io_stream @param origin The reference point for the seek. @return The error code and new absolute position. */ - virtual capy::io_result + virtual capy::results seek(std::int64_t offset, file_base::seek_basis origin) noexcept = 0; }; @@ -346,7 +346,7 @@ class BOOST_COROSIO_DECL stream_file : public io_stream @return The error code and new absolute position. */ - [[nodiscard]] capy::io_result seek( + [[nodiscard]] capy::results seek( std::int64_t offset, file_base::seek_basis origin = file_base::seek_set) noexcept; diff --git a/include/boost/corosio/tcp_acceptor.hpp b/include/boost/corosio/tcp_acceptor.hpp index fd18b2cd1..fa693ea4e 100644 --- a/include/boost/corosio/tcp_acceptor.hpp +++ b/include/boost/corosio/tcp_acceptor.hpp @@ -20,12 +20,12 @@ #include #include #include -#include +#include #include #include #include #include -#include +#include #include #include @@ -123,7 +123,7 @@ class BOOST_COROSIO_DECL tcp_acceptor : public io_object discard_peer(acc_, peer_impl_); } - [[nodiscard]] capy::io_result<> await_resume() const noexcept + [[nodiscard]] capy::results<> await_resume() const noexcept { if (!this->ec_ && peer_impl_) peer_.h_.reset(std::exchange(peer_impl_, nullptr)); @@ -161,7 +161,7 @@ class BOOST_COROSIO_DECL tcp_acceptor : public io_object discard_peer(acc_, peer_impl_); } - [[nodiscard]] capy::io_result await_resume() noexcept + [[nodiscard]] capy::results await_resume() noexcept { // The peer is built only on success: error paths must not // touch acc_.context(), which a moved-from acceptor lacks. @@ -379,7 +379,7 @@ class BOOST_COROSIO_DECL tcp_acceptor : public io_object @param peer The socket to receive the accepted connection. Any existing connection on this socket is closed. - @return An awaitable that completes with `io_result<>`. + @return An awaitable that completes with `results<>`. Returns success on successful accept, or an error code on failure including: - `operation_canceled`: Cancelled via stop_token or cancel(). @@ -419,7 +419,7 @@ class BOOST_COROSIO_DECL tcp_acceptor : public io_object triggered, the operation completes immediately with `errc::operation_canceled`. - @return An awaitable that completes with `io_result`. + @return An awaitable that completes with `results`. On success the payload is the connected peer socket; on failure (including cancellation) the error code is set and the payload socket is unconnected. Errors include: @@ -461,7 +461,7 @@ class BOOST_COROSIO_DECL tcp_acceptor : public io_object @param w The wait direction. - @return An awaitable that completes with `io_result<>`. + @return An awaitable that completes with `results<>`. A closed acceptor completes with `errc::bad_file_descriptor`. diff --git a/include/boost/corosio/tcp_server.hpp b/include/boost/corosio/tcp_server.hpp index 63ad220f3..f38db98b0 100644 --- a/include/boost/corosio/tcp_server.hpp +++ b/include/boost/corosio/tcp_server.hpp @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include #include @@ -306,7 +306,7 @@ class BOOST_COROSIO_DECL tcp_server // Owns the connection's chain: abandoning it resumes, or has // the executor destroy, this frame to unwind the task. capy::chain_owner owner_; - capy::io_env env_; + capy::await_context env_; /// Embedded post node: the start posts this instead of the /// bare handle, which would heap-allocate a wrapper op. capy::continuation cont_; @@ -356,15 +356,15 @@ class BOOST_COROSIO_DECL tcp_server // LCOV_EXCL_STOP } - // Inject io_env for IoAwaitable - template + // Inject await_context for ContextAwaitable + template auto await_transform(Awaitable&& a) { using AwaitableT = std::decay_t; struct adapter { AwaitableT aw; - capy::io_env const* env; + capy::await_context const* env; bool await_ready() { @@ -503,7 +503,7 @@ class BOOST_COROSIO_DECL tcp_server std::coroutine_handle<> await_suspend( - std::coroutine_handle<> h, capy::io_env const* env) noexcept + std::coroutine_handle<> h, capy::await_context const* env) noexcept { cont_.h = h; // A root has no owner: the launcher's would unwind it on the @@ -531,7 +531,7 @@ class BOOST_COROSIO_DECL tcp_server } bool - await_suspend(std::coroutine_handle<> h, capy::io_env const* env) noexcept + await_suspend(std::coroutine_handle<> h, capy::await_context const* env) noexcept { std::lock_guard lock(st_.mutex); if (st_.stopping) diff --git a/include/boost/corosio/tcp_socket.hpp b/include/boost/corosio/tcp_socket.hpp index 954daab3d..c2052a68a 100644 --- a/include/boost/corosio/tcp_socket.hpp +++ b/include/boost/corosio/tcp_socket.hpp @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include @@ -381,7 +381,7 @@ class BOOST_COROSIO_DECL tcp_socket : public io_stream @param ep The remote endpoint to connect to. - @return An awaitable that completes with `io_result<>`. + @return An awaitable that completes with `results<>`. Returns success (default `error_code`) on successful connection, or an error code on failure including: - `connection_refused`: No server listening at endpoint @@ -421,7 +421,7 @@ class BOOST_COROSIO_DECL tcp_socket : public io_stream @param w The wait direction (read, write, or error). - @return An awaitable that completes with `io_result<>`. + @return An awaitable that completes with `results<>`. On success, the wait consumes no bytes from the stream; a subsequent `read_some` (for read waits) returns the available data. diff --git a/include/boost/corosio/test/mocket.hpp b/include/boost/corosio/test/mocket.hpp index 284ab8fd2..c334a56b8 100644 --- a/include/boost/corosio/test/mocket.hpp +++ b/include/boost/corosio/test/mocket.hpp @@ -19,9 +19,9 @@ #include #include #include -#include +#include #include -#include +#include #include #include @@ -378,7 +378,7 @@ class basic_mocket::read_some_awaitable read_some_awaitable& operator=(read_some_awaitable const&) = delete; read_some_awaitable& operator=(read_some_awaitable&&) = delete; - // All decisions wait for await_suspend, where the io_env (and thus + // All decisions wait for await_suspend, where the await_context (and thus // the stop token) is available — a pre-stopped token must // short-circuit before any staged data is consumed. bool await_ready() const noexcept @@ -386,7 +386,7 @@ class basic_mocket::read_some_awaitable return false; } - auto await_suspend(std::coroutine_handle<> h, capy::io_env const* env) + auto await_suspend(std::coroutine_handle<> h, capy::await_context const* env) -> std::coroutine_handle<> { if (env->stop_token.stop_requested()) @@ -428,7 +428,7 @@ class basic_mocket::read_some_awaitable return underlying_.await_suspend(h, env); } - [[nodiscard]] capy::io_result await_resume() + [[nodiscard]] capy::results await_resume() { if (sync_) return {ec_, n_}; @@ -486,7 +486,7 @@ class basic_mocket::write_some_awaitable write_some_awaitable& operator=(write_some_awaitable const&) = delete; write_some_awaitable& operator=(write_some_awaitable&&) = delete; - // All decisions wait for await_suspend, where the io_env (and thus + // All decisions wait for await_suspend, where the await_context (and thus // the stop token) is available — a pre-stopped token must // short-circuit before any of the expect script is consumed. bool await_ready() const noexcept @@ -494,7 +494,7 @@ class basic_mocket::write_some_awaitable return false; } - auto await_suspend(std::coroutine_handle<> h, capy::io_env const* env) + auto await_suspend(std::coroutine_handle<> h, capy::await_context const* env) -> std::coroutine_handle<> { if (env->stop_token.stop_requested()) @@ -540,7 +540,7 @@ class basic_mocket::write_some_awaitable return underlying_.await_suspend(h, env); } - [[nodiscard]] capy::io_result await_resume() + [[nodiscard]] capy::results await_resume() { if (sync_) return {ec_, n_}; diff --git a/include/boost/corosio/timeout.hpp b/include/boost/corosio/timeout.hpp index 3a39d6ee5..fd14f06d0 100644 --- a/include/boost/corosio/timeout.hpp +++ b/include/boost/corosio/timeout.hpp @@ -13,7 +13,7 @@ #include #include -#include +#include #include #include @@ -21,12 +21,12 @@ namespace boost::corosio { -/** Race an io_result-returning awaitable against a deadline. +/** Race a `results`-returning awaitable against a deadline. Starts the awaitable with an interposed stop token and arms a timer. If the awaitable finishes first, its result is returned as-is (success, error, or exception). If the deadline passes - first, the awaitable is cancelled and an `io_result` whose + first, the awaitable is cancelled and a `results` whose `ec` compares equal to `capy::cond::timeout` (with a default-initialized payload) is produced. @@ -52,13 +52,13 @@ namespace boost::corosio { @param dur The maximum duration to wait, measured from suspension. - @return An awaitable yielding `io_result` matching the inner + @return An awaitable yielding `results` matching the inner awaitable's result type. @see delay */ -template - requires detail::is_io_result_v< +template + requires detail::is_results_v< std::remove_cvref_t>> && std::is_default_constructible_v< std::remove_cvref_t>> @@ -76,7 +76,7 @@ timeout(A a, std::chrono::duration dur) return detail::timeout_awaitable(std::move(a), ns); } -/** Race an io_result-returning awaitable against an absolute deadline. +/** Race a `results`-returning awaitable against an absolute deadline. Behaves as the duration overload with the deadline fixed at `tp` instead of measured from suspension. @@ -85,13 +85,13 @@ timeout(A a, std::chrono::duration dur) @param tp The steady-clock time point at which the awaitable is cancelled. - @return An awaitable yielding `io_result` matching the inner + @return An awaitable yielding `results` matching the inner awaitable's result type. @see delay */ -template - requires detail::is_io_result_v< +template + requires detail::is_results_v< std::remove_cvref_t>> && std::is_default_constructible_v< std::remove_cvref_t>> diff --git a/include/boost/corosio/tls_stream.hpp b/include/boost/corosio/tls_stream.hpp index c6f32fbb8..72ec290db 100644 --- a/include/boost/corosio/tls_stream.hpp +++ b/include/boost/corosio/tls_stream.hpp @@ -16,7 +16,8 @@ #include #include #include -#include +#include +#include #include #include @@ -196,7 +197,7 @@ class BOOST_COROSIO_DECL tls_stream @return An awaitable yielding `(error_code)`. */ - [[nodiscard]] virtual capy::io_task<> handshake(tls_role role) = 0; + [[nodiscard]] virtual capy::task> handshake(tls_role role) = 0; /** Asynchronously perform a graceful TLS shutdown. @@ -216,7 +217,7 @@ class BOOST_COROSIO_DECL tls_stream @return An awaitable yielding `(error_code)`. */ - [[nodiscard]] virtual capy::io_task<> shutdown() = 0; + [[nodiscard]] virtual capy::task> shutdown() = 0; /** Cancel operations pending on the owned underlying stream. @@ -351,7 +352,7 @@ class BOOST_COROSIO_DECL tls_stream @return An awaitable yielding `(error_code,std::size_t)`. */ - virtual capy::io_task do_read_some( + virtual capy::task> do_read_some( capy::detail::mutable_buffer_array buffers) = 0; @@ -364,7 +365,7 @@ class BOOST_COROSIO_DECL tls_stream @return An awaitable yielding `(error_code,std::size_t)`. */ - virtual capy::io_task do_write_some( + virtual capy::task> do_write_some( capy::detail::const_buffer_array buffers) = 0; }; diff --git a/include/boost/corosio/udp_socket.hpp b/include/boost/corosio/udp_socket.hpp index 105e575b3..9314137f0 100644 --- a/include/boost/corosio/udp_socket.hpp +++ b/include/boost/corosio/udp_socket.hpp @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include #include @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include @@ -699,7 +699,7 @@ class BOOST_COROSIO_DECL udp_socket : public io_object @param flags Message flags (e.g. message_flags::do_not_route). @return An awaitable that completes with - `io_result`. + `results`. A closed socket reports `errc::bad_file_descriptor`. */ @@ -728,7 +728,7 @@ class BOOST_COROSIO_DECL udp_socket : public io_object @param flags Message flags (e.g. message_flags::peek). @return An awaitable that completes with - `io_result`. + `results`. A closed socket reports `errc::bad_file_descriptor`. */ @@ -756,7 +756,7 @@ class BOOST_COROSIO_DECL udp_socket : public io_object @param ep The remote endpoint to connect to. - @return An awaitable that completes with `io_result<>`. + @return An awaitable that completes with `results<>`. If the socket needs to be opened and the open fails, the awaitable completes immediately with that error. @@ -779,7 +779,7 @@ class BOOST_COROSIO_DECL udp_socket : public io_object @param w The wait direction (read, write, or error). - @return An awaitable that completes with `io_result<>`. + @return An awaitable that completes with `results<>`. A closed socket completes with `errc::bad_file_descriptor`. @@ -796,7 +796,7 @@ class BOOST_COROSIO_DECL udp_socket : public io_object @param flags Message flags. @return An awaitable that completes with - `io_result`. + `results`. A closed socket reports `errc::bad_file_descriptor`. */ @@ -822,7 +822,7 @@ class BOOST_COROSIO_DECL udp_socket : public io_object @param flags Message flags (e.g. message_flags::peek). @return An awaitable that completes with - `io_result`. + `results`. A closed socket reports `errc::bad_file_descriptor`. */ diff --git a/include/boost/corosio/win_object_handle.hpp b/include/boost/corosio/win_object_handle.hpp index ab04202bd..06a993d4c 100644 --- a/include/boost/corosio/win_object_handle.hpp +++ b/include/boost/corosio/win_object_handle.hpp @@ -20,10 +20,10 @@ #include #include #include -#include +#include #include #include -#include +#include #include #include @@ -284,7 +284,7 @@ class BOOST_COROSIO_DECL win_object_handle : public io_object shared object is unsafe. There is no timeout parameter; compose with @ref timeout or a stop token. - @return An awaitable yielding `capy::io_result<>`. Yields + @return An awaitable yielding `capy::results<>`. Yields `errc::bad_file_descriptor` when not open and a code comparing equal to `capy::cond::canceled` when cancelled before the kernel satisfied the wait. diff --git a/include/boost/corosio/win_random_access_handle.hpp b/include/boost/corosio/win_random_access_handle.hpp index 7135cc19f..20a8f6961 100644 --- a/include/boost/corosio/win_random_access_handle.hpp +++ b/include/boost/corosio/win_random_access_handle.hpp @@ -21,10 +21,10 @@ #include #include #include -#include +#include #include #include -#include +#include #include #include diff --git a/include/boost/corosio/wolfssl_stream.hpp b/include/boost/corosio/wolfssl_stream.hpp index f633e5792..73633db4c 100644 --- a/include/boost/corosio/wolfssl_stream.hpp +++ b/include/boost/corosio/wolfssl_stream.hpp @@ -18,7 +18,8 @@ #include #include #include -#include +#include +#include #include #include @@ -148,7 +149,7 @@ class BOOST_COROSIO_DECL wolfssl_stream final : public tls_stream @return An awaitable yielding `(error_code)`. */ - [[nodiscard]] capy::io_task<> handshake(tls_role role) override; + [[nodiscard]] capy::task> handshake(tls_role role) override; /** Asynchronously shut down the TLS session. @@ -169,7 +170,7 @@ class BOOST_COROSIO_DECL wolfssl_stream final : public tls_stream @return An awaitable yielding `(error_code)`. */ - [[nodiscard]] capy::io_task<> shutdown() override; + [[nodiscard]] capy::task> shutdown() override; /// Cancel operations pending on the owned underlying stream. void cancel() noexcept override; @@ -207,12 +208,12 @@ class BOOST_COROSIO_DECL wolfssl_stream final : public tls_stream protected: /// @copydoc tls_stream::do_read_some - capy::io_task do_read_some( + capy::task> do_read_some( capy::detail::mutable_buffer_array buffers) override; /// @copydoc tls_stream::do_write_some - capy::io_task do_write_some( + capy::task> do_write_some( capy::detail::const_buffer_array buffers) override; diff --git a/src/corosio/src/endpoint.cpp b/src/corosio/src/endpoint.cpp index f77f5f164..63f735b91 100644 --- a/src/corosio/src/endpoint.cpp +++ b/src/corosio/src/endpoint.cpp @@ -154,7 +154,7 @@ parse_endpoint_impl(std::string_view s, endpoint& ep) noexcept } } -capy::io_result +capy::results make_endpoint(std::string_view s) noexcept { endpoint ep; diff --git a/src/corosio/src/host_name.cpp b/src/corosio/src/host_name.cpp index e0886748d..4dbd69412 100644 --- a/src/corosio/src/host_name.cpp +++ b/src/corosio/src/host_name.cpp @@ -26,7 +26,7 @@ namespace boost::corosio { #if BOOST_COROSIO_POSIX -capy::io_result +capy::results host_name() { // 256 exceeds POSIX's _POSIX_HOST_NAME_MAX floor of 255 and @@ -44,7 +44,7 @@ host_name() #elif BOOST_COROSIO_HAS_IOCP -capy::io_result +capy::results host_name() { // Size query: returns ERROR_MORE_DATA and writes the required diff --git a/src/corosio/src/ip_address.cpp b/src/corosio/src/ip_address.cpp index e6be61010..92c116a32 100644 --- a/src/corosio/src/ip_address.cpp +++ b/src/corosio/src/ip_address.cpp @@ -32,7 +32,7 @@ operator<<(std::ostream& os, ip_address const& addr) return addr.is_v4() ? os << addr.v4_ : os << addr.v6_; } -capy::io_result +capy::results make_ip_address(std::string_view s) noexcept { if (auto [ec, v4] = make_ipv4_address(s); !ec) diff --git a/src/corosio/src/ipv4_address.cpp b/src/corosio/src/ipv4_address.cpp index 2980eff0b..8366fda66 100644 --- a/src/corosio/src/ipv4_address.cpp +++ b/src/corosio/src/ipv4_address.cpp @@ -208,7 +208,7 @@ parse_ipv4_impl(std::string_view s, ipv4_address& addr) noexcept return {}; } -capy::io_result +capy::results make_ipv4_address(std::string_view s) noexcept { ipv4_address addr; diff --git a/src/corosio/src/ipv6_address.cpp b/src/corosio/src/ipv6_address.cpp index 4bc5dc162..2f0169217 100644 --- a/src/corosio/src/ipv6_address.cpp +++ b/src/corosio/src/ipv6_address.cpp @@ -533,7 +533,7 @@ parse_zone(std::string_view s, std::uint32_t& out) noexcept } // namespace -capy::io_result +capy::results make_ipv6_address(std::string_view s) noexcept { std::uint32_t scope_id = 0; diff --git a/src/corosio/src/stream_file.cpp b/src/corosio/src/stream_file.cpp index 6cea766e2..e23bb3e00 100644 --- a/src/corosio/src/stream_file.cpp +++ b/src/corosio/src/stream_file.cpp @@ -133,7 +133,7 @@ stream_file::assign(native_handle_type handle) noexcept return get().assign(handle); } -capy::io_result +capy::results stream_file::seek(std::int64_t offset, file_base::seek_basis origin) noexcept { if (!is_open()) diff --git a/src/corosio/src/tls/detail/engine_driver.hpp b/src/corosio/src/tls/detail/engine_driver.hpp index 56f2fb1f5..193f6d899 100644 --- a/src/corosio/src/tls/detail/engine_driver.hpp +++ b/src/corosio/src/tls/detail/engine_driver.hpp @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include @@ -561,7 +561,7 @@ class engine_driver used_ = false; } - capy::io_task do_read_some( + capy::task> do_read_some( capy::detail::mutable_buffer_array buffers) { if (auto ec = take_pending_flush_ec()) @@ -652,7 +652,7 @@ class engine_driver co_return {std::error_code{}, total_read}; } - capy::io_task do_write_some( + capy::task> do_write_some( capy::detail::const_buffer_array buffers) { if (auto ec = take_pending_flush_ec()) @@ -747,7 +747,7 @@ class engine_driver co_return {std::error_code{}, total_written}; } - capy::io_task<> do_handshake(tls_role role) + capy::task> do_handshake(tls_role role) { // Refuse the handshake while the engine's configuration is // unusable, before consuming any per-connection state. @@ -822,7 +822,7 @@ class engine_driver } } - capy::io_task<> do_shutdown() + capy::task> do_shutdown() { if (auto ec = take_pending_flush_ec()) co_return {ec}; @@ -925,7 +925,7 @@ class driver_ref /// Read through a driver an operation keeps alive. template -capy::io_task +capy::task> driver_read_some( driver_ref d, capy::detail::mutable_buffer_array buffers) @@ -935,7 +935,7 @@ driver_read_some( /// Write through a driver an operation keeps alive. template -capy::io_task +capy::task> driver_write_some( driver_ref d, capy::detail::const_buffer_array buffers) @@ -945,7 +945,7 @@ driver_write_some( /// Handshake through a driver an operation keeps alive. template -capy::io_task<> +capy::task> driver_handshake(driver_ref d, tls_role role) { co_return co_await d->do_handshake(role); @@ -953,7 +953,7 @@ driver_handshake(driver_ref d, tls_role role) /// Shut down through a driver an operation keeps alive. template -capy::io_task<> +capy::task> driver_shutdown(driver_ref d) { co_return co_await d->do_shutdown(); diff --git a/src/openssl/src/openssl_stream.cpp b/src/openssl/src/openssl_stream.cpp index e317778f9..9b077b0b2 100644 --- a/src/openssl/src/openssl_stream.cpp +++ b/src/openssl/src/openssl_stream.cpp @@ -91,7 +91,7 @@ openssl_stream::next_layer() const noexcept return impl_->stream(); } -capy::io_task +capy::task> openssl_stream::do_read_some( capy::detail::mutable_buffer_array buffers) { @@ -99,7 +99,7 @@ openssl_stream::do_read_some( detail::driver_ref(impl_), buffers); } -capy::io_task +capy::task> openssl_stream::do_write_some( capy::detail::const_buffer_array buffers) { @@ -107,14 +107,14 @@ openssl_stream::do_write_some( detail::driver_ref(impl_), buffers); } -capy::io_task<> +capy::task> openssl_stream::handshake(tls_role role) { return detail::driver_handshake( detail::driver_ref(impl_), role); } -capy::io_task<> +capy::task> openssl_stream::shutdown() { return detail::driver_shutdown(detail::driver_ref(impl_)); diff --git a/src/wolfssl/src/wolfssl_stream.cpp b/src/wolfssl/src/wolfssl_stream.cpp index a84659e9e..75f82eaa8 100644 --- a/src/wolfssl/src/wolfssl_stream.cpp +++ b/src/wolfssl/src/wolfssl_stream.cpp @@ -90,7 +90,7 @@ wolfssl_stream::next_layer() const noexcept return impl_->stream(); } -capy::io_task +capy::task> wolfssl_stream::do_read_some( capy::detail::mutable_buffer_array buffers) { @@ -98,7 +98,7 @@ wolfssl_stream::do_read_some( detail::driver_ref(impl_), buffers); } -capy::io_task +capy::task> wolfssl_stream::do_write_some( capy::detail::const_buffer_array buffers) { @@ -106,14 +106,14 @@ wolfssl_stream::do_write_some( detail::driver_ref(impl_), buffers); } -capy::io_task<> +capy::task> wolfssl_stream::handshake(tls_role role) { return detail::driver_handshake( detail::driver_ref(impl_), role); } -capy::io_task<> +capy::task> wolfssl_stream::shutdown() { return detail::driver_shutdown(detail::driver_ref(impl_)); diff --git a/test/doc/snippets/4d_sockets.cpp b/test/doc/snippets/4d_sockets.cpp index ac74ccce6..301204fab 100644 --- a/test/doc/snippets/4d_sockets.cpp +++ b/test/doc/snippets/4d_sockets.cpp @@ -55,7 +55,7 @@ namespace capy = boost::capy; #include #include #include -#include +#include #include #include #include @@ -180,7 +180,7 @@ template requires std::convertible_to< std::ranges::range_reference_t, typename Socket::endpoint_type> -capy::task> +capy::task> connect(Socket& s, Range endpoints); // end::connect_signature[] diff --git a/test/doc/snippets/4g_composed_operations.cpp b/test/doc/snippets/4g_composed_operations.cpp index 09d39623e..84491da5d 100644 --- a/test/doc/snippets/4g_composed_operations.cpp +++ b/test/doc/snippets/4g_composed_operations.cpp @@ -74,13 +74,13 @@ namespace synopsis { // tag::read_signature[] auto read(capy::ReadStream auto& stream, capy::MutableBufferSequence auto buffers) - -> capy::io_task; + -> capy::task>; // end::read_signature[] // tag::write_signature[] auto write(capy::WriteStream auto& stream, capy::ConstBufferSequence auto buffers) - -> capy::io_task; + -> capy::task>; // end::write_signature[] // tag::slice_interface[] diff --git a/test/doc/snippets/4l_tls.cpp b/test/doc/snippets/4l_tls.cpp index 17cb634a4..8cd100c66 100644 --- a/test/doc/snippets/4l_tls.cpp +++ b/test/doc/snippets/4l_tls.cpp @@ -146,8 +146,8 @@ class tls_stream template auto write_some(B const& buffers); // Encrypt and write - virtual capy::io_task<> handshake(tls_role role) = 0; - virtual capy::io_task<> shutdown() = 0; + virtual capy::task> handshake(tls_role role) = 0; + virtual capy::task> shutdown() = 0; virtual capy::any_stream& next_layer() noexcept = 0; // Underlying stream }; diff --git a/test/doc/snippets/4m_error_handling.cpp b/test/doc/snippets/4m_error_handling.cpp index 4676f6b80..24e48f645 100644 --- a/test/doc/snippets/4m_error_handling.cpp +++ b/test/doc/snippets/4m_error_handling.cpp @@ -383,16 +383,16 @@ struct error_handling_test { void testResultShapes() { - using capy::io_result; + using capy::results; // tag::result_shapes[] // Void result (connect, handshake) - io_result<> r1; // Contains: ec + results<> r1; // Contains: ec // Single value (read_some, write_some) - io_result r2; // Contains: ec, n (bytes transferred) + results r2; // Contains: ec, n (bytes transferred) // Typed result (resolve) - io_result> r3; // Contains: ec, results + results> r3; // Contains: ec, results // end::result_shapes[] BOOST_TEST(!std::get<0>(r1)); BOOST_TEST(!std::get<0>(r2)); diff --git a/test/unit/continuation_post.cpp b/test/unit/continuation_post.cpp index 017809d14..fa13d3486 100644 --- a/test/unit/continuation_post.cpp +++ b/test/unit/continuation_post.cpp @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include @@ -39,7 +39,7 @@ struct bare_post_awaitable } void - await_suspend(std::coroutine_handle<> h, capy::io_env const* env) noexcept + await_suspend(std::coroutine_handle<> h, capy::await_context const* env) noexcept { cont->h = h; env->executor.post(*cont); diff --git a/test/unit/delay.cpp b/test/unit/delay.cpp index e6b6c734c..f18a77887 100644 --- a/test/unit/delay.cpp +++ b/test/unit/delay.cpp @@ -124,21 +124,21 @@ struct count_on_exit // Namespace scope: GCC 11 miscompiles a co_await in a static member // coroutine of a class template. -static capy::task> +static capy::task> parked_child(int& down) { count_on_exit g{down}; co_return co_await delay(std::chrono::hours(1)); } -static capy::task> +static capy::task> queued_child(io_context& ioc, int& down) { count_on_exit g{down}; detail::timer t(ioc); t.expires_after(std::chrono::nanoseconds(0)); auto [ec] = co_await t.wait(); - co_return capy::io_result<>{ec}; + co_return capy::results<>{ec}; } template @@ -354,7 +354,7 @@ struct delay_test capy::thread_pool pool(1); auto ex = pool.get_executor(); delay_awaitable da(std::chrono::milliseconds(1)); - capy::io_env env{ex, {}, {}}; + capy::await_context env{ex, {}, {}}; BOOST_TEST_THROWS( da.await_suspend(std::noop_coroutine(), &env), std::logic_error); } diff --git a/test/unit/fault/iocp_faults.cpp b/test/unit/fault/iocp_faults.cpp index d54ae7104..2bf82ee3b 100644 --- a/test/unit/fault/iocp_faults.cpp +++ b/test/unit/fault/iocp_faults.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include @@ -71,7 +71,7 @@ struct post_awaitable } void - await_suspend(std::coroutine_handle<> h, capy::io_env const* env) noexcept + await_suspend(std::coroutine_handle<> h, capy::await_context const* env) noexcept { cont->h = h; env->executor.post(*cont); diff --git a/test/unit/io_context.cpp b/test/unit/io_context.cpp index 47b16dfbf..ab3b4682c 100644 --- a/test/unit/io_context.cpp +++ b/test/unit/io_context.cpp @@ -319,11 +319,11 @@ post_coro(io_context::executor_type& ex, std::coroutine_handle<> h) ex.post(h); } -inline capy::task> +inline capy::task> set_event_task(capy::async_event& evt) { evt.set(); - co_return capy::io_result<>{std::error_code{}}; + co_return capy::results<>{std::error_code{}}; } inline capy::task diff --git a/test/unit/mt_reactor.cpp b/test/unit/mt_reactor.cpp index d7d1696c8..8d27235af 100644 --- a/test/unit/mt_reactor.cpp +++ b/test/unit/mt_reactor.cpp @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include #include @@ -192,7 +192,7 @@ struct mt_reactor_test done.store(true); }; // Runs the waiter on this thread up to the parked wait. - capy::io_env env{ex, std::stop_token{}, nullptr}; + capy::await_context env{ex, std::stop_token{}, nullptr}; std::optional> parked; parked.emplace(waiter()); parked->await_suspend(std::noop_coroutine(), &env).resume(); diff --git a/test/unit/native/iocp/handle_error_map.cpp b/test/unit/native/iocp/handle_error_map.cpp index 2d867b12b..2818fc373 100644 --- a/test/unit/native/iocp/handle_error_map.cpp +++ b/test/unit/native/iocp/handle_error_map.cpp @@ -23,7 +23,7 @@ struct win_handle_error_map_test { void testReadEndOfDataBecomesZero() { - // Zero with zero bytes decodes as eof in decode_io_result. + // Zero with zero bytes decodes as eof in decode_results. BOOST_TEST_EQ(normalize_handle_error(ERROR_HANDLE_EOF, true), 0u); BOOST_TEST_EQ(normalize_handle_error(ERROR_BROKEN_PIPE, true), 0u); } diff --git a/test/unit/openssl_stream.cpp b/test/unit/openssl_stream.cpp index e4e17fded..e0a58ee21 100644 --- a/test/unit/openssl_stream.cpp +++ b/test/unit/openssl_stream.cpp @@ -265,7 +265,7 @@ struct openssl_stream_test std::error_code inject_ec_{}; template - capy::io_task read_some(MutableBufferSequence buffers) + capy::task> read_some(MutableBufferSequence buffers) { if (eof_reads_) co_return {std::error_code{}, 0}; @@ -273,7 +273,7 @@ struct openssl_stream_test } template - capy::io_task write_some(ConstBufferSequence buffers) + capy::task> write_some(ConstBufferSequence buffers) { if (fail_writes_) co_return {inject_ec_, 0}; diff --git a/test/unit/random_access_file.cpp b/test/unit/random_access_file.cpp index 5b5197c70..0ff5085d4 100644 --- a/test/unit/random_access_file.cpp +++ b/test/unit/random_access_file.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/test/unit/resolver.cpp b/test/unit/resolver.cpp index e433fa368..f198343af 100644 --- a/test/unit/resolver.cpp +++ b/test/unit/resolver.cpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include @@ -774,9 +774,9 @@ struct resolver_test BOOST_TEST_EQ(resolve_count, 3); } - // io_result tests + // `results` tests - void testIoResultSuccess() + void testResultsSuccess() { io_context ioc; resolver r(ioc); @@ -796,7 +796,7 @@ struct resolver_test BOOST_TEST(result_ok); } - void testIoResultError() + void testResultsError() { io_context ioc; resolver r(ioc); @@ -819,7 +819,7 @@ struct resolver_test BOOST_TEST(result_ec); } - void testIoResultStructuredBinding() + void testResultsStructuredBinding() { io_context ioc; resolver r(ioc); @@ -1432,10 +1432,10 @@ struct resolver_test // Sequential resolves testSequentialResolves(); - // io_result - testIoResultSuccess(); - testIoResultError(); - testIoResultStructuredBinding(); + // `results` + testResultsSuccess(); + testResultsError(); + testResultsStructuredBinding(); // resolve_flags testResolveFlagsOperators(); diff --git a/test/unit/signal_set.cpp b/test/unit/signal_set.cpp index 0079c13f9..278e031ad 100644 --- a/test/unit/signal_set.cpp +++ b/test/unit/signal_set.cpp @@ -15,7 +15,7 @@ #include #include -#include +#include #include #include @@ -1122,9 +1122,9 @@ struct signal_set_test BOOST_TEST_EQ(delivered, 40); } - // io_result tests + // `results` tests - void testIoResultSuccess() + void testResultsSuccess() { io_context ioc(Backend); signal_set s(ioc, SIGINT); @@ -1144,7 +1144,7 @@ struct signal_set_test BOOST_TEST(result_ok); } - void testIoResultCanceled() + void testResultsCanceled() { io_context ioc(Backend); signal_set s(ioc, SIGINT); @@ -1172,7 +1172,7 @@ struct signal_set_test BOOST_TEST(result_ec == capy::cond::canceled); } - void testIoResultStructuredBinding() + void testResultsStructuredBinding() { io_context ioc(Backend); signal_set s(ioc, SIGINT); @@ -1554,7 +1554,7 @@ struct signal_set_test std::ignore = co_await set.wait(); ++count; }; - capy::io_env env{ex, std::stop_token{}, nullptr}; + capy::await_context env{ex, std::stop_token{}, nullptr}; std::optional> parked; parked.emplace(waiter(s2, resumed2)); parked->await_suspend(std::noop_coroutine(), &env).resume(); @@ -1640,10 +1640,10 @@ struct signal_set_test testManySequentialSignalCycles(); testInterleavedQueuedAndWaitedSignals(); - // io_result tests - testIoResultSuccess(); - testIoResultCanceled(); - testIoResultStructuredBinding(); + // `results` tests + testResultsSuccess(); + testResultsCanceled(); + testResultsStructuredBinding(); // Signal flags tests (cross-platform) testFlagsBitwiseOperations(); diff --git a/test/unit/stream_file.cpp b/test/unit/stream_file.cpp index 8f960ca7a..e65a67a54 100644 --- a/test/unit/stream_file.cpp +++ b/test/unit/stream_file.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include diff --git a/test/unit/timeout.cpp b/test/unit/timeout.cpp index 7eb46448a..8a96305d6 100644 --- a/test/unit/timeout.cpp +++ b/test/unit/timeout.cpp @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include @@ -44,7 +44,7 @@ namespace boost::corosio { -// Immediately-resuming awaitable yielding io_result, used to +// Immediately-resuming awaitable yielding `results`, used to // verify payload preservation through timeout()'s pass-through path. struct payload_awaitable { @@ -57,11 +57,11 @@ struct payload_awaitable return false; } std::coroutine_handle<> - await_suspend(std::coroutine_handle<> h, capy::io_env const*) + await_suspend(std::coroutine_handle<> h, capy::await_context const*) { return h; } - capy::io_result await_resume() noexcept + capy::results await_resume() noexcept { return {std::error_code(), value_}; } @@ -72,11 +72,11 @@ struct payload_awaitable // cond::canceled. Used to confirm that timeout()'s deadline-win path // discards the inner payload rather than merely rewriting `ec` in // place. -inline capy::task> +inline capy::task> stop_only_payload() { auto [ec] = co_await delay(std::chrono::seconds(10)); - co_return capy::io_result{ec, 99}; + co_return capy::results{ec, 99}; } // Counts the blocks it hands out that are still live. @@ -188,11 +188,11 @@ struct timeout_test return false; } std::coroutine_handle<> - await_suspend(std::coroutine_handle<> h, capy::io_env const*) + await_suspend(std::coroutine_handle<> h, capy::await_context const*) { return h; } - capy::io_result<> await_resume() noexcept + capy::results<> await_resume() noexcept { return {make_error_code(std::errc::connection_refused)}; } @@ -221,11 +221,11 @@ struct timeout_test return false; } std::coroutine_handle<> - await_suspend(std::coroutine_handle<> h, capy::io_env const*) + await_suspend(std::coroutine_handle<> h, capy::await_context const*) { return h; } - capy::io_result<> await_resume() + capy::results<> await_resume() { throw std::runtime_error("boom"); } @@ -302,12 +302,12 @@ struct timeout_test return true; } std::coroutine_handle<> - await_suspend(std::coroutine_handle<> h, capy::io_env const*) + await_suspend(std::coroutine_handle<> h, capy::await_context const*) { *suspended_ = true; return h; } - capy::io_result await_resume() noexcept + capy::results await_resume() noexcept { return {std::error_code(), value_}; } @@ -341,11 +341,11 @@ struct timeout_test return true; } std::coroutine_handle<> - await_suspend(std::coroutine_handle<> h, capy::io_env const*) + await_suspend(std::coroutine_handle<> h, capy::await_context const*) { return h; } - capy::io_result<> await_resume() noexcept + capy::results<> await_resume() noexcept { return {make_error_code(capy::error::canceled)}; } @@ -634,7 +634,7 @@ struct timeout_test capy::thread_pool pool(1); auto ex = pool.get_executor(); auto ta = timeout(payload_awaitable(0), std::chrono::milliseconds(1)); - capy::io_env env{ex, {}, {}}; + capy::await_context env{ex, {}, {}}; BOOST_TEST_THROWS( ta.await_suspend(std::noop_coroutine(), &env), std::logic_error); } diff --git a/test/unit/tls_stream_tests.hpp b/test/unit/tls_stream_tests.hpp index 11f12490c..614e27e7a 100644 --- a/test/unit/tls_stream_tests.hpp +++ b/test/unit/tls_stream_tests.hpp @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include @@ -1688,7 +1688,7 @@ testUnawaitedReadOutlivesContext(StreamFactory make_stream) { auto client_ctx = make_client_context(); char buf[16]; - std::optional> op; + std::optional>> op; { io_context ioc; auto [m1, m2] = corosio::test::make_mocket_pair(ioc); @@ -1714,7 +1714,7 @@ testUnawaitedReadOutlivesUnwoundOwner(StreamFactory make_stream) auto server_ctx = make_server_context(); char buf[16]; char spare[16]; - std::optional> op; + std::optional>> op; { io_context ioc; auto [m1, m2] = corosio::test::make_mocket_pair(ioc); @@ -1725,7 +1725,7 @@ testUnawaitedReadOutlivesUnwoundOwner(StreamFactory make_stream) ioc.restart(); auto owner = [](std::unique_ptr s, - std::optional>& o, + std::optional>>& o, char* b, char* sp) -> capy::task<> { o.emplace(s->read_some(capy::mutable_buffer(sp, 16))); std::ignore = co_await s->read_some(capy::mutable_buffer(b, 16)); @@ -1859,7 +1859,7 @@ struct posted_resume return false; } - void await_suspend(std::coroutine_handle<> h, capy::io_env const* env) + void await_suspend(std::coroutine_handle<> h, capy::await_context const* env) { c.h = h; env->executor.post(c); @@ -1878,13 +1878,13 @@ struct partial_write_transport int* armed_writes; template - capy::io_task read_some(Buffers buffers) + capy::task> read_some(Buffers buffers) { co_return co_await m.read_some(buffers); } template - capy::io_task write_some(Buffers buffers) + capy::task> write_some(Buffers buffers) { if (*armed) { @@ -2659,7 +2659,7 @@ testFullDuplex(StreamFactory make_stream) bool failsafe_hit = false; std::stop_source failsafe_stop; - auto server_reader = [&]() -> capy::io_task<> { + auto server_reader = [&]() -> capy::task> { char buf[4096]; for (;;) { @@ -2669,7 +2669,7 @@ testFullDuplex(StreamFactory make_stream) co_return {ec}; } }; - auto server_writer = [&]() -> capy::io_task<> { + auto server_writer = [&]() -> capy::task> { auto [ec, n] = co_await capy::write( server, capy::const_buffer(reply.data(), reply.size())); BOOST_TEST(!ec); @@ -2783,7 +2783,7 @@ testFullDuplexBulk(StreamFactory make_stream) std::size_t sent = 0, received = 0; bool order_ok = true; - auto sender = [&]() -> capy::io_task<> { + auto sender = [&]() -> capy::task> { while (sent < total) { auto [ec, n] = co_await capy::write( @@ -2794,7 +2794,7 @@ testFullDuplexBulk(StreamFactory make_stream) } co_return {std::error_code{}}; }; - auto receiver = [&]() -> capy::io_task<> { + auto receiver = [&]() -> capy::task> { char buf[chunk_size]; while (received < total) { @@ -2895,14 +2895,14 @@ testRecordBoundaryTransfer(StreamFactory make_stream) std::string const payload(size, fill); std::string got; - auto sender = [&]() -> capy::io_task<> { + auto sender = [&]() -> capy::task> { auto [ec, n] = co_await capy::write( from, capy::const_buffer(payload.data(), payload.size())); BOOST_TEST(!ec); BOOST_TEST_EQ(n, size); co_return {ec}; }; - auto receiver = [&]() -> capy::io_task<> { + auto receiver = [&]() -> capy::task> { char buf[8192]; while (got.size() < size) { @@ -2997,14 +2997,14 @@ testShutdownOverRead(StreamFactory make_stream) // The server parks a read, then shuts down while it is parked. The // reader must complete with eof (peer close_notify), not hang. - auto server_reader = [&]() -> capy::io_task<> { + auto server_reader = [&]() -> capy::task> { char buf[256]; auto [ec, n] = co_await server.read_some(capy::mutable_buffer(buf, sizeof(buf))); reader_eof = (ec == capy::cond::eof); co_return {ec}; }; - auto server_shutdown = [&]() -> capy::io_task<> { + auto server_shutdown = [&]() -> capy::task> { auto [ec] = co_await server.shutdown(); local_sd_ok = !ec; co_return {ec}; @@ -3075,7 +3075,7 @@ struct gated_stream capy::async_event* write_gate_ = nullptr; template - capy::io_task read_some(MutableBufferSequence buffers) + capy::task> read_some(MutableBufferSequence buffers) { auto [ec, n] = co_await m_->read_some(buffers); // Withheld regardless of outcome: an errored completion must @@ -3087,7 +3087,7 @@ struct gated_stream } template - capy::io_task write_some(ConstBufferSequence buffers) + capy::task> write_some(ConstBufferSequence buffers) { if (write_gate_) { @@ -3150,7 +3150,7 @@ testShutdownSimultaneousClose(StreamFactory make_stream) gs.read_gate_ = &read_gate; gs.write_gate_ = &write_gate; - auto client_reader = [&]() -> capy::io_task<> { + auto client_reader = [&]() -> capy::task> { char buf[256]; auto [ec, n] = co_await client.read_some(capy::mutable_buffer(buf, sizeof(buf))); @@ -3160,7 +3160,7 @@ testShutdownSimultaneousClose(StreamFactory make_stream) // when_all stop-request the gated shutdown sibling. co_return {}; }; - auto client_shutdown = [&]() -> capy::io_task<> { + auto client_shutdown = [&]() -> capy::task> { auto [ec] = co_await client.shutdown(); local_sd_ok = !ec; co_return {ec}; @@ -3328,7 +3328,7 @@ struct partial_error_stream std::error_code inject_ec_{}; template - capy::io_task read_some(MutableBufferSequence buffers) + capy::task> read_some(MutableBufferSequence buffers) { auto [ec, n] = co_await m_->read_some(buffers); // Only override a clean result: this stream exists to prove @@ -3339,7 +3339,7 @@ struct partial_error_stream } template - capy::io_task write_some(ConstBufferSequence buffers) + capy::task> write_some(ConstBufferSequence buffers) { co_return co_await m_->write_some(buffers); } @@ -3616,7 +3616,7 @@ testFullDuplexMtStrand(StreamFactory make_stream) std::error_code client_write_ec; std::size_t client_got_size = 0; - auto server_reader = [&]() -> capy::io_task<> { + auto server_reader = [&]() -> capy::task> { char buf[2048]; for (;;) { @@ -3626,7 +3626,7 @@ testFullDuplexMtStrand(StreamFactory make_stream) co_return {ec}; } }; - auto server_writer = [&]() -> capy::io_task<> { + auto server_writer = [&]() -> capy::task> { auto [ec, n] = co_await capy::write( server, capy::const_buffer(reply.data(), reply.size())); co_return {ec};