diff --git a/doc/modules/ROOT/pages/4.servers/4b.route-handlers.adoc b/doc/modules/ROOT/pages/4.servers/4b.route-handlers.adoc index 010e639f..94ba41e7 100644 --- a/doc/modules/ROOT/pages/4.servers/4b.route-handlers.adoc +++ b/doc/modules/ROOT/pages/4.servers/4b.route-handlers.adoc @@ -526,7 +526,7 @@ object. [source,cpp] ---- -capy::io_task<> send(std::string_view body = {}); +capy::task> send(std::string_view body = {}); ---- This is where the real magic happens. `send()` is an asynchronous @@ -581,7 +581,7 @@ route_task my_handler(route_params& rp) } ---- -The return type is `io_task<>`, which yields a single `error_code` +The return type is `task>`, which yields a single `error_code` through structured bindings. If the send succeeds, `ec` is non-failing. If the client disconnected or a write error occurred, `ec` describes the failure and you can propagate it with diff --git a/include/boost/http/bcrypt.hpp b/include/boost/http/bcrypt.hpp index dd387798..4d4b06a0 100644 --- a/include/boost/http/bcrypt.hpp +++ b/include/boost/http/bcrypt.hpp @@ -41,7 +41,7 @@ #include #include #include -#include +#include #include #include @@ -516,7 +516,7 @@ struct hash_async_op void await_suspend( std::coroutine_handle cont, - capy::io_env const* env) + capy::await_context const* env) { cont_.h = cont; auto caller_ex = env->executor; @@ -561,7 +561,7 @@ struct compare_async_op void await_suspend( std::coroutine_handle cont, - capy::io_env const* env) + capy::await_context const* env) { cont_.h = cont; auto caller_ex = env->executor; diff --git a/include/boost/http/concept/buffer_sink.hpp b/include/boost/http/concept/buffer_sink.hpp index 37a20e74..8f87bdb1 100644 --- a/include/boost/http/concept/buffer_sink.hpp +++ b/include/boost/http/concept/buffer_sink.hpp @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include @@ -41,9 +41,9 @@ namespace http { @li `T` must provide a synchronous `prepare` member function accepting a `std::span` and returning a span of filled buffers - @li `T` must provide `commit(n)` returning an @ref capy::IoAwaitable that + @li `T` must provide `commit(n)` returning an @ref capy::ContextAwaitable that decomposes to `(error_code)` - @li `T` must provide `commit_eof(n)` returning an @ref capy::IoAwaitable + @li `T` must provide `commit_eof(n)` returning an @ref capy::ContextAwaitable that decomposes to `(error_code)` @par Semantic Requirements @@ -80,15 +80,15 @@ namespace http { @code std::span prepare( std::span dest ); - capy::IoAwaitable auto commit( std::size_t n ); - capy::IoAwaitable auto commit_eof( std::size_t n ); + capy::ContextAwaitable auto commit( std::size_t n ); + capy::ContextAwaitable auto commit_eof( std::size_t n ); @endcode @par Example @code template - io_task transfer( Source& source, Sink& sink ) + task> transfer( Source& source, Sink& sink ) { capy::const_buffer src_arr[16]; capy::mutable_buffer dst_arr[16]; @@ -117,7 +117,7 @@ namespace http { } @endcode - @see BufferSource, WriteSink, capy::IoAwaitable, capy::awaitable_decomposes_to + @see BufferSource, WriteSink, capy::ContextAwaitable, capy::awaitable_decomposes_to */ template concept BufferSink = @@ -127,13 +127,13 @@ concept BufferSink = { sink.prepare(dest) } -> std::same_as>; // Async: commit n bytes written - { sink.commit(n) } -> capy::IoAwaitable; + { sink.commit(n) } -> capy::ContextAwaitable; requires capy::awaitable_decomposes_to< decltype(sink.commit(n)), std::error_code>; // Async: commit n final bytes and signal end of data - { sink.commit_eof(n) } -> capy::IoAwaitable; + { sink.commit_eof(n) } -> capy::ContextAwaitable; requires capy::awaitable_decomposes_to< decltype(sink.commit_eof(n)), std::error_code>; diff --git a/include/boost/http/concept/buffer_source.hpp b/include/boost/http/concept/buffer_source.hpp index 6c400e82..a3f73e54 100644 --- a/include/boost/http/concept/buffer_source.hpp +++ b/include/boost/http/concept/buffer_source.hpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include @@ -40,7 +40,7 @@ namespace http { @li `T` must provide a `pull` member function accepting a `std::span` for output - @li The return type must satisfy @ref capy::IoAwaitable + @li The return type must satisfy @ref capy::ContextAwaitable @li The awaitable must decompose to `(error_code,std::span)` via structured bindings @li `T` must provide a `consume` member function accepting a byte count @@ -72,7 +72,7 @@ namespace http { @par Conforming Signatures @code - some_io_awaitable>> + some_context_awaitable>> pull( std::span dest ); void consume( std::size_t n ) noexcept; @@ -82,7 +82,7 @@ namespace http { @code template - io_task transfer( Source& source, Stream& stream ) + task> transfer( Source& source, Stream& stream ) { capy::const_buffer arr[16]; std::size_t total = 0; @@ -102,13 +102,13 @@ namespace http { } @endcode - @see capy::IoAwaitable, WriteSink, capy::awaitable_decomposes_to + @see capy::ContextAwaitable, WriteSink, capy::awaitable_decomposes_to */ template concept BufferSource = requires(T& src, std::span dest, std::size_t n) { - { src.pull(dest) } -> capy::IoAwaitable; + { src.pull(dest) } -> capy::ContextAwaitable; requires capy::awaitable_decomposes_to< decltype(src.pull(dest)), std::error_code, std::span>; diff --git a/include/boost/http/concept/read_source.hpp b/include/boost/http/concept/read_source.hpp index 2e69e9a3..910203d7 100644 --- a/include/boost/http/concept/read_source.hpp +++ b/include/boost/http/concept/read_source.hpp @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include @@ -41,7 +41,7 @@ namespace http { @li `T` must satisfy @ref capy::ReadStream (provides `read_some`) @li `T` must provide a `read` member function template accepting any @ref MutableBufferSequence - @li The return type of `read` must satisfy @ref capy::IoAwaitable + @li The return type of `read` must satisfy @ref capy::ContextAwaitable @li The awaitable must decompose to `(error_code, std::size_t)` via structured bindings @@ -87,10 +87,10 @@ namespace http { @code template< MutableBufferSequence MB > - capy::IoAwaitable auto read_some( MB buffers ); // inherited from capy::ReadStream + capy::ContextAwaitable auto read_some( MB buffers ); // inherited from capy::ReadStream template< MutableBufferSequence MB > - capy::IoAwaitable auto read( MB buffers ); + capy::ContextAwaitable auto read( MB buffers ); @endcode @warning **Coroutine Buffer Lifetime**: When implementing coroutine @@ -116,7 +116,7 @@ namespace http { } @endcode - @see capy::ReadStream, capy::IoAwaitable, MutableBufferSequence, + @see capy::ReadStream, capy::ContextAwaitable, MutableBufferSequence, capy::awaitable_decomposes_to */ template @@ -124,7 +124,7 @@ concept ReadSource = capy::ReadStream && requires(T& source, capy::mutable_buffer_archetype buffers) { - { source.read(buffers) } -> capy::IoAwaitable; + { source.read(buffers) } -> capy::ContextAwaitable; requires capy::awaitable_decomposes_to< decltype(source.read(buffers)), std::error_code, std::size_t>; diff --git a/include/boost/http/concept/write_sink.hpp b/include/boost/http/concept/write_sink.hpp index 293f84ab..057ccae1 100644 --- a/include/boost/http/concept/write_sink.hpp +++ b/include/boost/http/concept/write_sink.hpp @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include @@ -48,7 +48,7 @@ namespace http { @li `T` must provide a `write_eof` member function taking no arguments, returning an awaitable that decomposes to `(error_code)` - @li All return types must satisfy @ref capy::IoAwaitable + @li All return types must satisfy @ref capy::ContextAwaitable @par Semantic Requirements @@ -95,15 +95,15 @@ namespace http { @code template< ConstBufferSequence Buffers > - capy::IoAwaitable auto write_some( Buffers buffers ); // inherited + capy::ContextAwaitable auto write_some( Buffers buffers ); // inherited template< ConstBufferSequence Buffers > - capy::IoAwaitable auto write( Buffers buffers ); + capy::ContextAwaitable auto write( Buffers buffers ); template< ConstBufferSequence Buffers > - capy::IoAwaitable auto write_eof( Buffers buffers ); + capy::ContextAwaitable auto write_eof( Buffers buffers ); - capy::IoAwaitable auto write_eof(); + capy::ContextAwaitable auto write_eof(); @endcode @warning **Coroutine Buffer Lifetime**: When implementing coroutine @@ -137,7 +137,7 @@ namespace http { } @endcode - @see capy::WriteStream, capy::IoAwaitable, ConstBufferSequence, + @see capy::WriteStream, capy::ContextAwaitable, ConstBufferSequence, capy::awaitable_decomposes_to */ template @@ -145,15 +145,15 @@ concept WriteSink = capy::WriteStream && requires(T& sink, capy::const_buffer_archetype buffers) { - { sink.write(buffers) } -> capy::IoAwaitable; + { sink.write(buffers) } -> capy::ContextAwaitable; requires capy::awaitable_decomposes_to< decltype(sink.write(buffers)), std::error_code, std::size_t>; - { sink.write_eof(buffers) } -> capy::IoAwaitable; + { sink.write_eof(buffers) } -> capy::ContextAwaitable; requires capy::awaitable_decomposes_to< decltype(sink.write_eof(buffers)), std::error_code, std::size_t>; - { sink.write_eof() } -> capy::IoAwaitable; + { sink.write_eof() } -> capy::ContextAwaitable; requires capy::awaitable_decomposes_to< decltype(sink.write_eof()), std::error_code>; diff --git a/include/boost/http/io/any_buffer_sink.hpp b/include/boost/http/io/any_buffer_sink.hpp index e5c66ee6..685edf7b 100644 --- a/include/boost/http/io/any_buffer_sink.hpp +++ b/include/boost/http/io/any_buffer_sink.hpp @@ -16,11 +16,11 @@ #include #include #include -#include +#include #include -#include -#include -#include +#include +#include +#include #include #include @@ -292,7 +292,7 @@ class any_buffer_sink The wrapper must contain a valid sink (`has_value() == true`). */ template - capy::io_task + capy::task> write_some(CB buffers); /** Write all data from a buffer sequence. @@ -312,7 +312,7 @@ class any_buffer_sink The wrapper must contain a valid sink (`has_value() == true`). */ template - capy::io_task + capy::task> write(CB buffers); /** Atomically write data and signal end-of-stream. @@ -333,7 +333,7 @@ class any_buffer_sink The wrapper must contain a valid sink (`has_value() == true`). */ template - capy::io_task + capy::task> write_eof(CB buffers); /** Signal end-of-stream. @@ -401,21 +401,21 @@ class any_buffer_sink write_eof_buffers_(std::span buffers); }; -/** Type-erased ops for awaitables that await-return `capy::io_result<>`. */ +/** Type-erased ops for awaitables that await-return `capy::results<>`. */ struct any_buffer_sink::awaitable_ops { bool (*await_ready)(void*); - std::coroutine_handle<> (*await_suspend)(void*, std::coroutine_handle<>, capy::io_env const*); - capy::io_result<> (*await_resume)(void*); + std::coroutine_handle<> (*await_suspend)(void*, std::coroutine_handle<>, capy::await_context const*); + capy::results<> (*await_resume)(void*); void (*destroy)(void*) noexcept; }; -/** Type-erased ops for awaitables that await-return `capy::io_result`. */ +/** Type-erased ops for awaitables that await-return `capy::results`. */ struct any_buffer_sink::write_awaitable_ops { bool (*await_ready)(void*); - std::coroutine_handle<> (*await_suspend)(void*, std::coroutine_handle<>, capy::io_env const*); - capy::io_result (*await_resume)(void*); + std::coroutine_handle<> (*await_suspend)(void*, std::coroutine_handle<>, capy::await_context const*); + capy::results (*await_resume)(void*); void (*destroy)(void*) noexcept; }; @@ -490,7 +490,7 @@ struct any_buffer_sink::vtable_for_impl +[](void* p) { return static_cast(p)->await_ready(); }, - +[](void* p, std::coroutine_handle<> h, capy::io_env const* env) { + +[](void* p, std::coroutine_handle<> h, capy::await_context const* env) { return capy::detail::call_await_suspend( static_cast(p), h, env); }, @@ -517,7 +517,7 @@ struct any_buffer_sink::vtable_for_impl +[](void* p) { return static_cast(p)->await_ready(); }, - +[](void* p, std::coroutine_handle<> h, capy::io_env const* env) { + +[](void* p, std::coroutine_handle<> h, capy::await_context const* env) { return capy::detail::call_await_suspend( static_cast(p), h, env); }, @@ -547,7 +547,7 @@ struct any_buffer_sink::vtable_for_impl +[](void* p) { return static_cast(p)->await_ready(); }, - +[](void* p, std::coroutine_handle<> h, capy::io_env const* env) { + +[](void* p, std::coroutine_handle<> h, capy::await_context const* env) { return capy::detail::call_await_suspend( static_cast(p), h, env); }, @@ -577,7 +577,7 @@ struct any_buffer_sink::vtable_for_impl +[](void* p) { return static_cast(p)->await_ready(); }, - +[](void* p, std::coroutine_handle<> h, capy::io_env const* env) { + +[](void* p, std::coroutine_handle<> h, capy::await_context const* env) { return capy::detail::call_await_suspend( static_cast(p), h, env); }, @@ -607,7 +607,7 @@ struct any_buffer_sink::vtable_for_impl +[](void* p) { return static_cast(p)->await_ready(); }, - +[](void* p, std::coroutine_handle<> h, capy::io_env const* env) { + +[](void* p, std::coroutine_handle<> h, capy::await_context const* env) { return capy::detail::call_await_suspend( static_cast(p), h, env); }, @@ -635,7 +635,7 @@ struct any_buffer_sink::vtable_for_impl +[](void* p) { return static_cast(p)->await_ready(); }, - +[](void* p, std::coroutine_handle<> h, capy::io_env const* env) { + +[](void* p, std::coroutine_handle<> h, capy::await_context const* env) { return capy::detail::call_await_suspend( static_cast(p), h, env); }, @@ -823,13 +823,13 @@ any_buffer_sink::commit(std::size_t n) } 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) { return self_->active_ops_->await_suspend( self_->cached_awaitable_, h, env); } - capy::io_result<> + capy::results<> await_resume() { struct guard { @@ -865,13 +865,13 @@ any_buffer_sink::commit_eof(std::size_t n) } 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) { return self_->active_ops_->await_suspend( self_->cached_awaitable_, h, env); } - capy::io_result<> + capy::results<> await_resume() { struct guard { @@ -904,7 +904,7 @@ any_buffer_sink::write_some_( } 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) { self_->active_write_ops_ = self_->vt_->construct_write_some_awaitable( @@ -920,7 +920,7 @@ any_buffer_sink::write_some_( self_->cached_awaitable_, h, env); } - capy::io_result + capy::results await_resume() { struct guard { @@ -954,7 +954,7 @@ any_buffer_sink::write_( } 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) { self_->active_write_ops_ = self_->vt_->construct_write_awaitable( @@ -970,7 +970,7 @@ any_buffer_sink::write_( self_->cached_awaitable_, h, env); } - capy::io_result + capy::results await_resume() { struct guard { @@ -1004,7 +1004,7 @@ any_buffer_sink::write_eof_buffers_( } 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) { self_->active_write_ops_ = self_->vt_->construct_write_eof_buffers_awaitable( @@ -1020,7 +1020,7 @@ any_buffer_sink::write_eof_buffers_( self_->cached_awaitable_, h, env); } - capy::io_result + capy::results await_resume() { struct guard { @@ -1039,7 +1039,7 @@ any_buffer_sink::write_eof_buffers_( } template -capy::io_task +capy::task> any_buffer_sink::write_some(CB buffers) { capy::buffer_param bp(buffers); @@ -1072,7 +1072,7 @@ any_buffer_sink::write_some(CB buffers) } template -capy::io_task +capy::task> any_buffer_sink::write(CB buffers) { capy::buffer_param bp(buffers); @@ -1156,13 +1156,13 @@ any_buffer_sink::write_eof() } 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) { return self_->active_ops_->await_suspend( self_->cached_awaitable_, h, env); } - capy::io_result<> + capy::results<> await_resume() { struct guard { @@ -1180,7 +1180,7 @@ any_buffer_sink::write_eof() } template -capy::io_task +capy::task> any_buffer_sink::write_eof(CB buffers) { // Native WriteSink path diff --git a/include/boost/http/io/any_buffer_source.hpp b/include/boost/http/io/any_buffer_source.hpp index eaaea086..31a91f55 100644 --- a/include/boost/http/io/any_buffer_source.hpp +++ b/include/boost/http/io/any_buffer_source.hpp @@ -16,12 +16,12 @@ #include #include #include -#include +#include #include #include -#include -#include -#include +#include +#include +#include #include #include @@ -265,7 +265,7 @@ class any_buffer_source @see pull, consume */ template - capy::io_task + capy::task> read_some(MB buffers); /** Read data into a mutable buffer sequence. @@ -289,7 +289,7 @@ class any_buffer_source @see pull, consume */ template - capy::io_task + capy::task> read(MB buffers); protected: @@ -332,21 +332,21 @@ class any_buffer_source read_(std::span buffers); }; -/** Type-erased ops for awaitables that await-return `capy::io_result>`. */ +/** Type-erased ops for awaitables that await-return `capy::results>`. */ struct any_buffer_source::awaitable_ops { bool (*await_ready)(void*); - std::coroutine_handle<> (*await_suspend)(void*, std::coroutine_handle<>, capy::io_env const*); - capy::io_result> (*await_resume)(void*); + std::coroutine_handle<> (*await_suspend)(void*, std::coroutine_handle<>, capy::await_context const*); + capy::results> (*await_resume)(void*); void (*destroy)(void*) noexcept; }; -/** Type-erased ops for awaitables that await-return `capy::io_result`. */ +/** Type-erased ops for awaitables that await-return `capy::results`. */ struct any_buffer_source::read_awaitable_ops { bool (*await_ready)(void*); - std::coroutine_handle<> (*await_suspend)(void*, std::coroutine_handle<>, capy::io_env const*); - capy::io_result (*await_resume)(void*); + std::coroutine_handle<> (*await_suspend)(void*, std::coroutine_handle<>, capy::await_context const*); + capy::results (*await_resume)(void*); void (*destroy)(void*) noexcept; }; @@ -404,7 +404,7 @@ struct any_buffer_source::vtable_for_impl +[](void* p) { return static_cast(p)->await_ready(); }, - +[](void* p, std::coroutine_handle<> h, capy::io_env const* env) { + +[](void* p, std::coroutine_handle<> h, capy::await_context const* env) { return capy::detail::call_await_suspend( static_cast(p), h, env); }, @@ -434,7 +434,7 @@ struct any_buffer_source::vtable_for_impl +[](void* p) { return static_cast(p)->await_ready(); }, - +[](void* p, std::coroutine_handle<> h, capy::io_env const* env) { + +[](void* p, std::coroutine_handle<> h, capy::await_context const* env) { return capy::detail::call_await_suspend( static_cast(p), h, env); }, @@ -464,7 +464,7 @@ struct any_buffer_source::vtable_for_impl +[](void* p) { return static_cast(p)->await_ready(); }, - +[](void* p, std::coroutine_handle<> h, capy::io_env const* env) { + +[](void* p, std::coroutine_handle<> h, capy::await_context const* env) { return capy::detail::call_await_suspend( static_cast(p), h, env); }, @@ -631,13 +631,13 @@ any_buffer_source::pull(std::span dest) } 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) { return self_->active_ops_->await_suspend( self_->cached_awaitable_, h, env); } - capy::io_result> + capy::results> await_resume() { struct guard { @@ -670,7 +670,7 @@ any_buffer_source::read_some_( } 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) { self_->active_read_ops_ = self_->vt_->construct_read_some_awaitable( @@ -686,7 +686,7 @@ any_buffer_source::read_some_( self_->cached_awaitable_, h, env); } - capy::io_result + capy::results await_resume() { struct guard { @@ -720,7 +720,7 @@ any_buffer_source::read_( } 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) { self_->active_read_ops_ = self_->vt_->construct_read_awaitable( @@ -736,7 +736,7 @@ any_buffer_source::read_( self_->cached_awaitable_, h, env); } - capy::io_result + capy::results await_resume() { struct guard { @@ -755,7 +755,7 @@ any_buffer_source::read_( } template -capy::io_task +capy::task> any_buffer_source::read_some(MB buffers) { capy::buffer_param bp(buffers); @@ -779,7 +779,7 @@ any_buffer_source::read_some(MB buffers) } template -capy::io_task +capy::task> any_buffer_source::read(MB buffers) { capy::buffer_param bp(buffers); diff --git a/include/boost/http/io/any_read_source.hpp b/include/boost/http/io/any_read_source.hpp index 7c775f4a..9d613f9c 100644 --- a/include/boost/http/io/any_read_source.hpp +++ b/include/boost/http/io/any_read_source.hpp @@ -15,11 +15,11 @@ #include #include #include -#include +#include #include -#include -#include -#include +#include +#include +#include #include #include @@ -247,7 +247,7 @@ class any_read_source call returned an error (including EOF). */ template - capy::io_task + capy::task> read(MB buffers); protected: @@ -281,8 +281,8 @@ class any_read_source struct any_read_source::awaitable_ops { bool (*await_ready)(void*); - std::coroutine_handle<> (*await_suspend)(void*, std::coroutine_handle<>, capy::io_env const*); - capy::io_result (*await_resume)(void*); + std::coroutine_handle<> (*await_suspend)(void*, std::coroutine_handle<>, capy::await_context const*); + capy::results (*await_resume)(void*); void (*destroy)(void*) noexcept; }; @@ -329,7 +329,7 @@ struct any_read_source::vtable_for_impl +[](void* p) { return static_cast(p)->await_ready(); }, - +[](void* p, std::coroutine_handle<> h, capy::io_env const* env) { + +[](void* p, std::coroutine_handle<> h, capy::await_context const* env) { return capy::detail::call_await_suspend( static_cast(p), h, env); }, @@ -356,7 +356,7 @@ struct any_read_source::vtable_for_impl +[](void* p) { return static_cast(p)->await_ready(); }, - +[](void* p, std::coroutine_handle<> h, capy::io_env const* env) { + +[](void* p, std::coroutine_handle<> h, capy::await_context const* env) { return capy::detail::call_await_suspend( static_cast(p), h, env); }, @@ -488,7 +488,7 @@ any_read_source::read_some(MB buffers) } 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) { self_->active_ops_ = self_->vt_->construct_read_some_awaitable( self_->source_, @@ -502,7 +502,7 @@ any_read_source::read_some(MB buffers) self_->cached_awaitable_, h, env); } - capy::io_result + capy::results await_resume() { if(ba_.to_span().empty()) @@ -537,7 +537,7 @@ any_read_source::read_(std::span buffers) } 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) { self_->active_ops_ = self_->vt_->construct_read_awaitable( self_->source_, @@ -551,7 +551,7 @@ any_read_source::read_(std::span buffers) self_->cached_awaitable_, h, env); } - capy::io_result + capy::results await_resume() { struct guard { @@ -569,7 +569,7 @@ any_read_source::read_(std::span buffers) } template -capy::io_task +capy::task> any_read_source::read(MB buffers) { capy::buffer_param bp(buffers); diff --git a/include/boost/http/io/any_write_sink.hpp b/include/boost/http/io/any_write_sink.hpp index 44a895a2..c5c6a81e 100644 --- a/include/boost/http/io/any_write_sink.hpp +++ b/include/boost/http/io/any_write_sink.hpp @@ -15,12 +15,12 @@ #include #include #include -#include +#include #include #include -#include -#include -#include +#include +#include +#include #include #include @@ -241,7 +241,7 @@ class any_write_sink The wrapper must contain a valid sink (`has_value() == true`). */ template - capy::io_task + capy::task> write(CB buffers); /** Atomically write data and signal end-of-stream. @@ -271,7 +271,7 @@ class any_write_sink The wrapper must contain a valid sink (`has_value() == true`). */ template - capy::io_task + capy::task> write_eof(CB buffers); /** Signal end of data. @@ -329,16 +329,16 @@ class any_write_sink struct any_write_sink::write_awaitable_ops { bool (*await_ready)(void*); - std::coroutine_handle<> (*await_suspend)(void*, std::coroutine_handle<>, capy::io_env const*); - capy::io_result (*await_resume)(void*); + std::coroutine_handle<> (*await_suspend)(void*, std::coroutine_handle<>, capy::await_context const*); + capy::results (*await_resume)(void*); void (*destroy)(void*) noexcept; }; struct any_write_sink::eof_awaitable_ops { bool (*await_ready)(void*); - std::coroutine_handle<> (*await_suspend)(void*, std::coroutine_handle<>, capy::io_env const*); - capy::io_result<> (*await_resume)(void*); + std::coroutine_handle<> (*await_suspend)(void*, std::coroutine_handle<>, capy::await_context const*); + capy::results<> (*await_resume)(void*); void (*destroy)(void*) noexcept; }; @@ -394,7 +394,7 @@ struct any_write_sink::vtable_for_impl +[](void* p) { return static_cast(p)->await_ready(); }, - +[](void* p, std::coroutine_handle<> h, capy::io_env const* env) { + +[](void* p, std::coroutine_handle<> h, capy::await_context const* env) { return capy::detail::call_await_suspend( static_cast(p), h, env); }, @@ -421,7 +421,7 @@ struct any_write_sink::vtable_for_impl +[](void* p) { return static_cast(p)->await_ready(); }, - +[](void* p, std::coroutine_handle<> h, capy::io_env const* env) { + +[](void* p, std::coroutine_handle<> h, capy::await_context const* env) { return capy::detail::call_await_suspend( static_cast(p), h, env); }, @@ -448,7 +448,7 @@ struct any_write_sink::vtable_for_impl +[](void* p) { return static_cast(p)->await_ready(); }, - +[](void* p, std::coroutine_handle<> h, capy::io_env const* env) { + +[](void* p, std::coroutine_handle<> h, capy::await_context const* env) { return capy::detail::call_await_suspend( static_cast(p), h, env); }, @@ -474,7 +474,7 @@ struct any_write_sink::vtable_for_impl +[](void* p) { return static_cast(p)->await_ready(); }, - +[](void* p, std::coroutine_handle<> h, capy::io_env const* env) { + +[](void* p, std::coroutine_handle<> h, capy::await_context const* env) { return capy::detail::call_await_suspend( static_cast(p), h, env); }, @@ -619,7 +619,7 @@ any_write_sink::write_some_( } 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) { self_->active_write_ops_ = self_->vt_->construct_write_some_awaitable( self_->sink_, @@ -633,7 +633,7 @@ any_write_sink::write_some_( self_->cached_awaitable_, h, env); } - capy::io_result + capy::results await_resume() { struct guard { @@ -666,7 +666,7 @@ any_write_sink::write_( } 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) { self_->active_write_ops_ = self_->vt_->construct_write_awaitable( self_->sink_, @@ -680,7 +680,7 @@ any_write_sink::write_( self_->cached_awaitable_, h, env); } - capy::io_result + capy::results await_resume() { struct guard { @@ -711,7 +711,7 @@ any_write_sink::write_eof() } 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) { // Construct the underlying awaitable into cached storage self_->active_eof_ops_ = self_->vt_->construct_eof_awaitable( @@ -727,7 +727,7 @@ any_write_sink::write_eof() self_->cached_awaitable_, h, env); } - capy::io_result<> + capy::results<> await_resume() { struct guard { @@ -760,7 +760,7 @@ any_write_sink::write_eof_buffers_( } 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) { self_->active_write_ops_ = self_->vt_->construct_write_eof_buffers_awaitable( @@ -775,7 +775,7 @@ any_write_sink::write_eof_buffers_( self_->cached_awaitable_, h, env); } - capy::io_result + capy::results await_resume() { struct guard { @@ -816,7 +816,7 @@ any_write_sink::write_some(CB buffers) } 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) { self_->active_write_ops_ = self_->vt_->construct_write_some_awaitable( self_->sink_, @@ -830,7 +830,7 @@ any_write_sink::write_some(CB buffers) self_->cached_awaitable_, h, env); } - capy::io_result + capy::results await_resume() { if(ba_.to_span().empty()) @@ -851,7 +851,7 @@ any_write_sink::write_some(CB buffers) } template -capy::io_task +capy::task> any_write_sink::write(CB buffers) { capy::const_buffer_param bp(buffers); @@ -874,7 +874,7 @@ any_write_sink::write(CB buffers) } template -capy::io_task +capy::task> any_write_sink::write_eof(CB buffers) { capy::const_buffer_param bp(buffers); diff --git a/include/boost/http/io/pull_from.hpp b/include/boost/http/io/pull_from.hpp index f2d97c96..6c70cd85 100644 --- a/include/boost/http/io/pull_from.hpp +++ b/include/boost/http/io/pull_from.hpp @@ -16,7 +16,8 @@ #include #include #include -#include +#include +#include #include #include @@ -60,7 +61,7 @@ namespace http { @see ReadSource, BufferSink, push_to */ template -capy::io_task +capy::task> pull_from(Src& source, Sink& sink) { capy::mutable_buffer dst_arr[capy::detail::max_iovec_]; @@ -140,7 +141,7 @@ pull_from(Src& source, Sink& sink) */ template requires (!ReadSource) -capy::io_task +capy::task> pull_from(Src& source, Sink& sink) { capy::mutable_buffer dst_arr[capy::detail::max_iovec_]; diff --git a/include/boost/http/io/push_to.hpp b/include/boost/http/io/push_to.hpp index d02261d0..21dcbbd9 100644 --- a/include/boost/http/io/push_to.hpp +++ b/include/boost/http/io/push_to.hpp @@ -16,7 +16,8 @@ #include #include #include -#include +#include +#include #include #include @@ -59,7 +60,7 @@ namespace http { @see BufferSource, WriteSink */ template -capy::io_task +capy::task> push_to(Src& source, Sink& sink) { capy::const_buffer arr[capy::detail::max_iovec_]; @@ -124,7 +125,7 @@ push_to(Src& source, Sink& sink) */ template requires (!WriteSink) -capy::io_task +capy::task> push_to(Src& source, Stream& stream) { capy::const_buffer arr[capy::detail::max_iovec_]; diff --git a/include/boost/http/json/json_sink.hpp b/include/boost/http/json/json_sink.hpp index cfaa6402..40664833 100644 --- a/include/boost/http/json/json_sink.hpp +++ b/include/boost/http/json/json_sink.hpp @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include @@ -57,7 +57,7 @@ class json_sink json::stream_parser parser_; template - capy::immediate> + capy::immediate> write_impl(CB const& buffers, bool eof) { std::error_code ec; @@ -122,7 +122,7 @@ class json_sink On success, returns the total bytes written. */ template - capy::immediate> + capy::immediate> write_some(CB const& buffers) { return write_impl(buffers, false); @@ -138,7 +138,7 @@ class json_sink On success, returns the total bytes written. */ template - capy::immediate> + capy::immediate> write(CB const& buffers) { return write_impl(buffers, false); @@ -156,7 +156,7 @@ class json_sink On success, returns the total bytes written. */ template - capy::immediate> + capy::immediate> write(CB const& buffers, bool eof) { return write_impl(buffers, eof); @@ -173,7 +173,7 @@ class json_sink On success, returns the total bytes written. */ template - capy::immediate> + capy::immediate> write_eof(CB const& buffers) { return write_impl(buffers, true); @@ -185,7 +185,7 @@ class json_sink @return An awaitable yielding `(error_code)`. */ - capy::immediate> + capy::immediate> write_eof() { std::error_code ec; diff --git a/include/boost/http/parser.hpp b/include/boost/http/parser.hpp index 9de7ce97..ce99062e 100644 --- a/include/boost/http/parser.hpp +++ b/include/boost/http/parser.hpp @@ -22,7 +22,8 @@ #include #include #include -#include +#include +#include #include #include @@ -359,7 +360,7 @@ class parser @see @ref read. */ template - capy::io_task<> + capy::task> read_header(Stream& stream); /** Asynchronously read a complete HTTP message. @@ -384,7 +385,7 @@ class parser @see @ref body, @ref read_header. */ template - capy::io_task<> + capy::task> read(Stream& stream); /** Asynchronously read body data into buffers. @@ -406,7 +407,7 @@ class parser @see @ref read_header. */ template - capy::io_task + capy::task> read(Stream& stream, MB buffers); /** Return a source for reading body data. @@ -450,7 +451,7 @@ class parser @see WriteSink. */ template - capy::io_task<> + capy::task> read(capy::ReadStream auto& stream, Sink&& sink); private: @@ -521,7 +522,7 @@ class parser::source @return An awaitable yielding `(error_code,std::span)`. */ - capy::io_task> + capy::task>> pull(std::span dest); /** Consume bytes from pulled body data. @@ -537,7 +538,7 @@ class parser::source }; template -capy::io_task<> +capy::task> parser:: read_header(Stream& stream) { @@ -565,7 +566,7 @@ read_header(Stream& stream) } template -capy::io_task<> +capy::task> parser:: read(Stream& stream) { @@ -596,7 +597,7 @@ read(Stream& stream) } template -capy::io_task +capy::task> parser:: read(Stream& stream, MB buffers) { @@ -658,7 +659,7 @@ source_for(Stream& stream) noexcept } template -capy::io_task> +capy::task>> parser::source:: pull(std::span dest) { @@ -716,7 +717,7 @@ consume(std::size_t n) noexcept } template -capy::io_task<> +capy::task> parser:: read(capy::ReadStream auto& stream, Sink&& sink) { diff --git a/include/boost/http/serializer.hpp b/include/boost/http/serializer.hpp index a9bce4e0..d8326689 100644 --- a/include/boost/http/serializer.hpp +++ b/include/boost/http/serializer.hpp @@ -18,7 +18,8 @@ #include #include #include -#include +#include +#include #include #include @@ -646,7 +647,7 @@ class serializer::sink */ auto commit(std::size_t n) - -> capy::io_task<> + -> capy::task> { if(sr_->is_start()) sr_->start_writes(); @@ -695,7 +696,7 @@ class serializer::sink */ auto commit_eof(std::size_t n) - -> capy::io_task<> + -> capy::task> { if(sr_->is_start()) sr_->start_writes(); @@ -743,7 +744,7 @@ class serializer::sink template auto write(ConstBufferSequence const& buffers) - -> capy::io_task + -> capy::task> { if(sr_->is_start()) sr_->start_buffers(); @@ -845,7 +846,7 @@ class serializer::sink template auto write_eof(ConstBufferSequence const& buffers) - -> capy::io_task + -> capy::task> { auto [ec, n] = co_await write(buffers); if(ec) @@ -892,7 +893,7 @@ class serializer::sink */ auto write_eof() - -> capy::io_task<> + -> capy::task> { if(sr_->is_start()) sr_->start_buffers(); diff --git a/include/boost/http/server/route_handler.hpp b/include/boost/http/server/route_handler.hpp index 5f12ac8c..985eee58 100644 --- a/include/boost/http/server/route_handler.hpp +++ b/include/boost/http/server/route_handler.hpp @@ -19,8 +19,7 @@ #include #include #include -#include -#include +#include #include #include #include @@ -442,7 +441,7 @@ class BOOST_HTTP_SYMBOL_VISIBLE /** Send the response with an optional body. */ - BOOST_HTTP_DECL capy::io_task<> send(std::string_view body = {}); + BOOST_HTTP_DECL capy::task> send(std::string_view body = {}); private: template diff --git a/include/boost/http/test/buffer_sink.hpp b/include/boost/http/test/buffer_sink.hpp index 60ef6dee..e41bf2c4 100644 --- a/include/boost/http/test/buffer_sink.hpp +++ b/include/boost/http/test/buffer_sink.hpp @@ -15,8 +15,8 @@ #include #include #include -#include -#include +#include +#include #include #include @@ -171,21 +171,21 @@ class buffer_sink bool await_ready() const noexcept { return false; } // The operation completes synchronously, but await_suspend is - // the only place capy::io_env is delivered (the promise's + // the only place capy::await_context is delivered (the promise's // transform_awaiter forwards it here). Returning false means // the coroutine does not actually suspend; it resumes - // immediately, having observed the stop token. See capy::io_env, - // IoAwaitable. + // immediately, having observed the stop token. See capy::await_context, + // ContextAwaitable. bool await_suspend( std::coroutine_handle<>, - capy::io_env const* env) noexcept + capy::await_context const* env) noexcept { canceled_ = env->stop_token.stop_requested(); return false; } - capy::io_result<> + capy::results<> await_resume() { if(canceled_) @@ -239,13 +239,13 @@ class buffer_sink bool await_suspend( std::coroutine_handle<>, - capy::io_env const* env) noexcept + capy::await_context const* env) noexcept { canceled_ = env->stop_token.stop_requested(); return false; } - capy::io_result<> + capy::results<> await_resume() { if(canceled_) diff --git a/include/boost/http/test/buffer_source.hpp b/include/boost/http/test/buffer_source.hpp index cd3d93ee..8c2749d7 100644 --- a/include/boost/http/test/buffer_source.hpp +++ b/include/boost/http/test/buffer_source.hpp @@ -16,8 +16,8 @@ #include #include #include -#include -#include +#include +#include #include #include @@ -161,21 +161,21 @@ class buffer_source bool await_ready() const noexcept { return false; } // The operation completes synchronously, but await_suspend is - // the only place capy::io_env is delivered (the promise's + // the only place capy::await_context is delivered (the promise's // transform_awaiter forwards it here). Returning false means // the coroutine does not actually suspend; it resumes - // immediately, having observed the stop token. See capy::io_env, - // IoAwaitable. + // immediately, having observed the stop token. See capy::await_context, + // ContextAwaitable. bool await_suspend( std::coroutine_handle<>, - capy::io_env const* env) noexcept + capy::await_context const* env) noexcept { canceled_ = env->stop_token.stop_requested(); return false; } - capy::io_result> + capy::results> await_resume() { if(canceled_) diff --git a/include/boost/http/test/read_source.hpp b/include/boost/http/test/read_source.hpp index 94385b16..36e5de7c 100644 --- a/include/boost/http/test/read_source.hpp +++ b/include/boost/http/test/read_source.hpp @@ -16,8 +16,8 @@ #include #include #include -#include -#include +#include +#include #include #include @@ -145,21 +145,21 @@ class read_source bool await_ready() const noexcept { return false; } // The operation completes synchronously, but await_suspend is - // the only place capy::io_env is delivered (the promise's + // the only place capy::await_context is delivered (the promise's // transform_awaiter forwards it here). Returning false means // the coroutine does not actually suspend; it resumes - // immediately, having observed the stop token. See capy::io_env, - // IoAwaitable. + // immediately, having observed the stop token. See capy::await_context, + // ContextAwaitable. bool await_suspend( std::coroutine_handle<>, - capy::io_env const* env) noexcept + capy::await_context const* env) noexcept { canceled_ = env->stop_token.stop_requested(); return false; } - capy::io_result + capy::results await_resume() { if(capy::buffer_empty(buffers_)) @@ -228,13 +228,13 @@ class read_source bool await_suspend( std::coroutine_handle<>, - capy::io_env const* env) noexcept + capy::await_context const* env) noexcept { canceled_ = env->stop_token.stop_requested(); return false; } - capy::io_result + capy::results await_resume() { if(capy::buffer_empty(buffers_)) diff --git a/include/boost/http/test/write_sink.hpp b/include/boost/http/test/write_sink.hpp index 00cc2c0f..eb355768 100644 --- a/include/boost/http/test/write_sink.hpp +++ b/include/boost/http/test/write_sink.hpp @@ -16,8 +16,8 @@ #include #include #include -#include -#include +#include +#include #include #include @@ -178,21 +178,21 @@ class write_sink bool await_ready() const noexcept { return false; } // The operation completes synchronously, but await_suspend is - // the only place capy::io_env is delivered (the promise's + // the only place capy::await_context is delivered (the promise's // transform_awaiter forwards it here). Returning false means // the coroutine does not actually suspend; it resumes - // immediately, having observed the stop token. See capy::io_env, - // IoAwaitable. + // immediately, having observed the stop token. See capy::await_context, + // ContextAwaitable. bool await_suspend( std::coroutine_handle<>, - capy::io_env const* env) noexcept + capy::await_context const* env) noexcept { canceled_ = env->stop_token.stop_requested(); return false; } - capy::io_result + capy::results await_resume() { if(capy::buffer_empty(buffers_)) @@ -270,13 +270,13 @@ class write_sink bool await_suspend( std::coroutine_handle<>, - capy::io_env const* env) noexcept + capy::await_context const* env) noexcept { canceled_ = env->stop_token.stop_requested(); return false; } - capy::io_result + capy::results await_resume() { if(canceled_) @@ -355,13 +355,13 @@ class write_sink bool await_suspend( std::coroutine_handle<>, - capy::io_env const* env) noexcept + capy::await_context const* env) noexcept { canceled_ = env->stop_token.stop_requested(); return false; } - capy::io_result + capy::results await_resume() { if(canceled_) @@ -435,13 +435,13 @@ class write_sink bool await_suspend( std::coroutine_handle<>, - capy::io_env const* env) noexcept + capy::await_context const* env) noexcept { canceled_ = env->stop_token.stop_requested(); return false; } - capy::io_result<> + capy::results<> await_resume() { if(canceled_) diff --git a/src/server/router_types.cpp b/src/server/router_types.cpp index e9890cc7..b51c7dde 100644 --- a/src/server/router_types.cpp +++ b/src/server/router_types.cpp @@ -125,7 +125,7 @@ is_method( //------------------------------------------------ -capy::io_task<> +capy::task> route_params:: send(std::string_view body) { diff --git a/test/unit/concept/buffer_sink.cpp b/test/unit/concept/buffer_sink.cpp index d08cf3af..08792324 100644 --- a/test/unit/concept/buffer_sink.cpp +++ b/test/unit/concept/buffer_sink.cpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include @@ -25,14 +25,14 @@ namespace http { namespace { using namespace capy; -// Mock IoAwaitable returning (error_code) +// Mock ContextAwaitable returning (error_code) struct mock_commit_awaitable { bool await_ready() const noexcept { return true; } void await_suspend( std::coroutine_handle<>, - io_env const*) const noexcept + await_context const*) const noexcept { } @@ -43,14 +43,14 @@ struct mock_commit_awaitable } }; -// Mock IoAwaitable returning wrong type (error_code, size_t) +// Mock ContextAwaitable returning wrong type (error_code, size_t) struct mock_commit_awaitable_wrong_type { bool await_ready() const noexcept { return true; } void await_suspend( std::coroutine_handle<>, - io_env const*) const noexcept + await_context const*) const noexcept { } @@ -61,7 +61,7 @@ struct mock_commit_awaitable_wrong_type } }; -// Mock awaitable missing IoAwaitable protocol +// Mock awaitable missing ContextAwaitable protocol struct mock_commit_awaitable_not_io { bool await_ready() const noexcept { return true; } @@ -171,7 +171,7 @@ struct invalid_buffer_sink_no_commit_eof } }; -// Invalid: commit is not IoAwaitable +// Invalid: commit is not ContextAwaitable struct invalid_buffer_sink_not_io { std::span @@ -253,7 +253,7 @@ static_assert(!BufferSink); static_assert(!BufferSink); static_assert(!BufferSink); -// Non-IoAwaitable does not satisfy BufferSink +// Non-ContextAwaitable does not satisfy BufferSink static_assert(!BufferSink); // Wrong prepare return type does not satisfy BufferSink diff --git a/test/unit/concept/buffer_source.cpp b/test/unit/concept/buffer_source.cpp index 83cb11c5..a339e9ab 100644 --- a/test/unit/concept/buffer_source.cpp +++ b/test/unit/concept/buffer_source.cpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include @@ -25,14 +25,14 @@ namespace http { namespace { using namespace capy; -// Mock IoAwaitable returning (error_code, span) +// Mock ContextAwaitable returning (error_code, span) struct mock_source_awaitable { bool await_ready() const noexcept { return true; } void await_suspend( std::coroutine_handle<>, - io_env const*) const noexcept + await_context const*) const noexcept { } @@ -43,14 +43,14 @@ struct mock_source_awaitable } }; -// Mock IoAwaitable returning wrong type (just error_code) +// Mock ContextAwaitable returning wrong type (just error_code) struct mock_source_awaitable_wrong_type { bool await_ready() const noexcept { return true; } void await_suspend( std::coroutine_handle<>, - io_env const*) const noexcept + await_context const*) const noexcept { } @@ -61,7 +61,7 @@ struct mock_source_awaitable_wrong_type } }; -// Mock awaitable missing IoAwaitable protocol +// Mock awaitable missing ContextAwaitable protocol struct mock_source_awaitable_not_io { bool await_ready() const noexcept { return true; } @@ -107,7 +107,7 @@ struct invalid_buffer_source_no_pull // No pull method }; -// Invalid: pull is not IoAwaitable +// Invalid: pull is not ContextAwaitable struct invalid_buffer_source_not_io { mock_source_awaitable_not_io @@ -160,7 +160,7 @@ static_assert(!BufferSource); // Missing methods do not satisfy BufferSource static_assert(!BufferSource); -// Non-IoAwaitable does not satisfy BufferSource +// Non-ContextAwaitable does not satisfy BufferSource static_assert(!BufferSource); // Non-awaitable return does not satisfy BufferSource diff --git a/test/unit/concept/read_source.cpp b/test/unit/concept/read_source.cpp index 5348c889..59836852 100644 --- a/test/unit/concept/read_source.cpp +++ b/test/unit/concept/read_source.cpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include @@ -25,14 +25,14 @@ namespace http { namespace { using namespace capy; -// Mock IoAwaitable returning (error_code, size_t) as pair +// Mock ContextAwaitable returning (error_code, size_t) as pair struct mock_source_awaitable_pair { bool await_ready() const noexcept { return true; } void await_suspend( std::coroutine_handle<>, - io_env const*) const noexcept + await_context const*) const noexcept { } @@ -43,14 +43,14 @@ struct mock_source_awaitable_pair } }; -// Mock IoAwaitable returning (error_code, size_t) as tuple +// Mock ContextAwaitable returning (error_code, size_t) as tuple struct mock_source_awaitable_tuple { bool await_ready() const noexcept { return true; } void await_suspend( std::coroutine_handle<>, - io_env const*) const noexcept + await_context const*) const noexcept { } @@ -61,14 +61,14 @@ struct mock_source_awaitable_tuple } }; -// Mock IoAwaitable with wrong return type (just error_code) +// Mock ContextAwaitable with wrong return type (just error_code) struct mock_source_awaitable_wrong_type { bool await_ready() const noexcept { return true; } void await_suspend( std::coroutine_handle<>, - io_env const*) const noexcept + await_context const*) const noexcept { } @@ -79,21 +79,21 @@ struct mock_source_awaitable_wrong_type } }; -// Mock IoAwaitable returning int +// Mock ContextAwaitable returning int struct mock_source_awaitable_int { bool await_ready() const noexcept { return true; } void await_suspend( std::coroutine_handle<>, - io_env const*) const noexcept + await_context const*) const noexcept { } int await_resume() const noexcept { return 0; } }; -// Mock awaitable missing IoAwaitable protocol +// Mock awaitable missing ContextAwaitable protocol struct mock_source_awaitable_not_io { bool await_ready() const noexcept { return true; } @@ -208,7 +208,7 @@ struct invalid_read_source_empty { }; -// Invalid: read is not IoAwaitable +// Invalid: read is not ContextAwaitable struct invalid_read_source_not_io { template @@ -263,7 +263,7 @@ static_assert(!ReadSource); // Missing everything does not satisfy ReadSource static_assert(!ReadSource); -// Non-IoAwaitable does not satisfy ReadSource +// Non-ContextAwaitable does not satisfy ReadSource static_assert(!ReadSource); // Non-awaitable return does not satisfy ReadSource diff --git a/test/unit/concept/write_sink.cpp b/test/unit/concept/write_sink.cpp index 4a2ed92e..dc99051f 100644 --- a/test/unit/concept/write_sink.cpp +++ b/test/unit/concept/write_sink.cpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include @@ -25,14 +25,14 @@ namespace http { namespace { using namespace capy; -// Mock IoAwaitable returning std::error_code (for write_eof()) +// Mock ContextAwaitable returning std::error_code (for write_eof()) struct mock_sink_awaitable { bool await_ready() const noexcept { return true; } void await_suspend( std::coroutine_handle<>, - io_env const*) const noexcept + await_context const*) const noexcept { } @@ -43,14 +43,14 @@ struct mock_sink_awaitable } }; -// Mock IoAwaitable returning (error_code, size_t) +// Mock ContextAwaitable returning (error_code, size_t) struct mock_sink_awaitable_with_size { bool await_ready() const noexcept { return true; } void await_suspend( std::coroutine_handle<>, - io_env const*) const noexcept + await_context const*) const noexcept { } @@ -61,21 +61,21 @@ struct mock_sink_awaitable_with_size } }; -// Mock IoAwaitable returning int +// Mock ContextAwaitable returning int struct mock_sink_awaitable_int { bool await_ready() const noexcept { return true; } void await_suspend( std::coroutine_handle<>, - io_env const*) const noexcept + await_context const*) const noexcept { } int await_resume() const noexcept { return 0; } }; -// Mock awaitable missing IoAwaitable protocol +// Mock awaitable missing ContextAwaitable protocol struct mock_sink_awaitable_not_io { bool await_ready() const noexcept { return true; } @@ -89,7 +89,7 @@ struct mock_sink_awaitable_not_io } }; -// Mock awaitable missing IoAwaitable protocol, returns (ec, size_t) +// Mock awaitable missing ContextAwaitable protocol, returns (ec, size_t) struct mock_sink_awaitable_with_size_not_io { bool await_ready() const noexcept { return true; } @@ -325,7 +325,7 @@ struct invalid_write_sink_no_write_eof_buffers } }; -// Invalid: write is not IoAwaitable +// Invalid: write is not ContextAwaitable struct invalid_write_sink_write_not_io { template @@ -356,7 +356,7 @@ struct invalid_write_sink_write_not_io } }; -// Invalid: write_eof() is not IoAwaitable +// Invalid: write_eof() is not ContextAwaitable struct invalid_write_sink_eof_not_io { template @@ -474,7 +474,7 @@ static_assert(!WriteSink); static_assert(!WriteSink); static_assert(!WriteSink); -// Non-IoAwaitable does not satisfy WriteSink +// Non-ContextAwaitable does not satisfy WriteSink static_assert(!WriteSink); static_assert(!WriteSink); diff --git a/test/unit/io/any_buffer_sink.cpp b/test/unit/io/any_buffer_sink.cpp index ec4f4fe9..f12625b6 100644 --- a/test/unit/io/any_buffer_sink.cpp +++ b/test/unit/io/any_buffer_sink.cpp @@ -15,8 +15,7 @@ #include #include -#include -#include +#include #include #include #include @@ -107,9 +106,9 @@ class buffer_write_sink std::size_t n_; bool await_ready() const noexcept { return true; } - void await_suspend(std::coroutine_handle<>, io_env const*) const noexcept {} + void await_suspend(std::coroutine_handle<>, await_context const*) const noexcept {} - io_result<> + results<> await_resume() { auto ec = self_->f_.maybe_fail(); @@ -132,9 +131,9 @@ class buffer_write_sink std::size_t n_; bool await_ready() const noexcept { return true; } - void await_suspend(std::coroutine_handle<>, io_env const*) const noexcept {} + void await_suspend(std::coroutine_handle<>, await_context const*) const noexcept {} - io_result<> + results<> await_resume() { auto ec = self_->f_.maybe_fail(); @@ -162,9 +161,9 @@ class buffer_write_sink CB buffers_; bool await_ready() const noexcept { return true; } - void await_suspend(std::coroutine_handle<>, io_env const*) const noexcept {} + void await_suspend(std::coroutine_handle<>, await_context const*) const noexcept {} - io_result + results await_resume() { self_->write_api_used_ = true; @@ -194,9 +193,9 @@ class buffer_write_sink CB buffers_; bool await_ready() const noexcept { return true; } - void await_suspend(std::coroutine_handle<>, io_env const*) const noexcept {} + void await_suspend(std::coroutine_handle<>, await_context const*) const noexcept {} - io_result + results await_resume() { self_->write_api_used_ = true; @@ -225,9 +224,9 @@ class buffer_write_sink CB buffers_; bool await_ready() const noexcept { return true; } - void await_suspend(std::coroutine_handle<>, io_env const*) const noexcept {} + void await_suspend(std::coroutine_handle<>, await_context const*) const noexcept {} - io_result + results await_resume() { self_->write_api_used_ = true; @@ -257,9 +256,9 @@ class buffer_write_sink buffer_write_sink* self_; bool await_ready() const noexcept { return true; } - void await_suspend(std::coroutine_handle<>, io_env const*) const noexcept {} + void await_suspend(std::coroutine_handle<>, await_context const*) const noexcept {} - io_result<> + results<> await_resume() { self_->write_api_used_ = true; @@ -288,18 +287,18 @@ struct resuming_eof_awaitable { bool await_ready() const noexcept { return false; } std::coroutine_handle<> - await_suspend(std::coroutine_handle<> h, io_env const*) noexcept + await_suspend(std::coroutine_handle<> h, await_context const*) noexcept { return h; } - io_result<> await_resume() { return {}; } + results<> await_resume() { return {}; } }; struct resuming_size_awaitable { bool await_ready() const noexcept { return false; } std::coroutine_handle<> - await_suspend(std::coroutine_handle<> h, io_env const*) noexcept + await_suspend(std::coroutine_handle<> h, await_context const*) noexcept { return h; } - io_result await_resume() { return {std::error_code(), 1}; } + results await_resume() { return {std::error_code(), 1}; } }; // Satisfies BufferSink + WriteSink with suspending operations. diff --git a/test/unit/io/any_buffer_source.cpp b/test/unit/io/any_buffer_source.cpp index ca37f7c0..d59d4c4c 100644 --- a/test/unit/io/any_buffer_source.cpp +++ b/test/unit/io/any_buffer_source.cpp @@ -16,8 +16,7 @@ #include #include -#include -#include +#include #include #include #include @@ -99,9 +98,9 @@ class buffer_read_source std::span dest_; bool await_ready() const noexcept { return true; } - void await_suspend(std::coroutine_handle<>, io_env const*) const noexcept {} + void await_suspend(std::coroutine_handle<>, await_context const*) const noexcept {} - io_result> + results> await_resume() { auto ec = self_->f_.maybe_fail(); @@ -139,9 +138,9 @@ class buffer_read_source MB buffers_; bool await_ready() const noexcept { return true; } - void await_suspend(std::coroutine_handle<>, io_env const*) const noexcept {} + void await_suspend(std::coroutine_handle<>, await_context const*) const noexcept {} - io_result + results await_resume() { self_->read_api_used_ = true; @@ -177,9 +176,9 @@ class buffer_read_source MB buffers_; bool await_ready() const noexcept { return true; } - void await_suspend(std::coroutine_handle<>, io_env const*) const noexcept {} + void await_suspend(std::coroutine_handle<>, await_context const*) const noexcept {} - io_result + results await_resume() { self_->read_api_used_ = true; @@ -215,9 +214,9 @@ struct resuming_pull_awaitable char const* data_; bool await_ready() const noexcept { return false; } std::coroutine_handle<> - await_suspend(std::coroutine_handle<> h, io_env const*) noexcept + await_suspend(std::coroutine_handle<> h, await_context const*) noexcept { return h; } - io_result> + results> await_resume() { if(dest_.empty()) @@ -227,13 +226,13 @@ struct resuming_pull_awaitable } }; -struct resuming_io_awaitable +struct resuming_context_awaitable { bool await_ready() const noexcept { return false; } std::coroutine_handle<> - await_suspend(std::coroutine_handle<> h, io_env const*) noexcept + await_suspend(std::coroutine_handle<> h, await_context const*) noexcept { return h; } - io_result await_resume() { return {std::error_code(), 3}; } + results await_resume() { return {std::error_code(), 3}; } }; // Satisfies BufferSource + ReadSource with suspending operations. @@ -244,9 +243,9 @@ struct resuming_buffer_source { return {dest, data_}; } void consume(std::size_t) noexcept {} template - resuming_io_awaitable read_some(MB) { return {}; } + resuming_context_awaitable read_some(MB) { return {}; } template - resuming_io_awaitable read(MB) { return {}; } + resuming_context_awaitable read(MB) { return {}; } }; // Move constructor throws so owning construction fails after storage @@ -262,9 +261,9 @@ struct throwing_move_buffer_source { return {dest, nullptr}; } void consume(std::size_t) noexcept {} template - resuming_io_awaitable read_some(MB) { return {}; } + resuming_context_awaitable read_some(MB) { return {}; } template - resuming_io_awaitable read(MB) { return {}; } + resuming_context_awaitable read(MB) { return {}; } }; // Verify concepts at compile time diff --git a/test/unit/io/any_read_source.cpp b/test/unit/io/any_read_source.cpp index 82d15e7a..94cab573 100644 --- a/test/unit/io/any_read_source.cpp +++ b/test/unit/io/any_read_source.cpp @@ -14,9 +14,8 @@ #include #include #include -#include -#include -#include +#include +#include #include #include @@ -45,9 +44,9 @@ struct pending_source_awaitable : counter_(std::exchange(o.counter_, nullptr)) {} ~pending_source_awaitable() { if(counter_) ++(*counter_); } bool await_ready() const noexcept { return false; } - std::coroutine_handle<> await_suspend(std::coroutine_handle<>, io_env const*) + std::coroutine_handle<> await_suspend(std::coroutine_handle<>, await_context const*) { return std::noop_coroutine(); } - io_result await_resume() + results await_resume() { return {std::error_code(), 0}; } }; @@ -68,9 +67,9 @@ struct resuming_source_awaitable { bool await_ready() const noexcept { return false; } std::coroutine_handle<> - await_suspend(std::coroutine_handle<> h, io_env const*) noexcept + await_suspend(std::coroutine_handle<> h, await_context const*) noexcept { return h; } - io_result await_resume() { return {std::error_code(), 5}; } + results await_resume() { return {std::error_code(), 5}; } }; struct resuming_read_source @@ -776,7 +775,7 @@ class any_read_source_test capy::test::blocking_context bctx; auto ex = bctx.get_executor(); - io_env env{executor_ref(ex), {}}; + await_context env{executor_ref(ex), {}}; aw.await_suspend( std::noop_coroutine(), &env); } @@ -796,7 +795,7 @@ class any_read_source_test capy::test::blocking_context bctx; auto ex = bctx.get_executor(); - io_env env{executor_ref(ex), {}}; + await_context env{executor_ref(ex), {}}; aw.await_suspend( std::noop_coroutine(), &env); diff --git a/test/unit/io/any_write_sink.cpp b/test/unit/io/any_write_sink.cpp index 2aebc914..606a028d 100644 --- a/test/unit/io/any_write_sink.cpp +++ b/test/unit/io/any_write_sink.cpp @@ -13,9 +13,8 @@ #include #include -#include -#include -#include +#include +#include #include #include @@ -45,9 +44,9 @@ struct pending_sink_awaitable : counter_(std::exchange(o.counter_, nullptr)) {} ~pending_sink_awaitable() { if(counter_) ++(*counter_); } bool await_ready() const noexcept { return false; } - std::coroutine_handle<> await_suspend(std::coroutine_handle<>, io_env const*) + std::coroutine_handle<> await_suspend(std::coroutine_handle<>, await_context const*) { return std::noop_coroutine(); } - io_result await_resume() + results await_resume() { return {std::error_code(), 0}; } }; @@ -59,9 +58,9 @@ struct pending_sink_eof_awaitable : counter_(std::exchange(o.counter_, nullptr)) {} ~pending_sink_eof_awaitable() { if(counter_) ++(*counter_); } bool await_ready() const noexcept { return false; } - std::coroutine_handle<> await_suspend(std::coroutine_handle<>, io_env const*) + std::coroutine_handle<> await_suspend(std::coroutine_handle<>, await_context const*) { return std::noop_coroutine(); } - io_result<> await_resume() + results<> await_resume() { return {}; } }; @@ -87,18 +86,18 @@ struct resuming_sink_awaitable { bool await_ready() const noexcept { return false; } std::coroutine_handle<> - await_suspend(std::coroutine_handle<> h, io_env const*) noexcept + await_suspend(std::coroutine_handle<> h, await_context const*) noexcept { return h; } - io_result await_resume() { return {std::error_code(), 1}; } + results await_resume() { return {std::error_code(), 1}; } }; struct resuming_sink_eof_awaitable { bool await_ready() const noexcept { return false; } std::coroutine_handle<> - await_suspend(std::coroutine_handle<> h, io_env const*) noexcept + await_suspend(std::coroutine_handle<> h, await_context const*) noexcept { return h; } - io_result<> await_resume() { return {}; } + results<> await_resume() { return {}; } }; struct resuming_write_sink @@ -636,7 +635,7 @@ class any_write_sink_test capy::test::blocking_context bctx; auto ex = bctx.get_executor(); - io_env env{executor_ref(ex), {}}; + await_context env{executor_ref(ex), {}}; aw.await_suspend(std::noop_coroutine(), &env); } BOOST_TEST_EQ(destroyed, 1); @@ -655,7 +654,7 @@ class any_write_sink_test capy::test::blocking_context bctx; auto ex = bctx.get_executor(); - io_env env{executor_ref(ex), {}}; + await_context env{executor_ref(ex), {}}; aw.await_suspend( std::noop_coroutine(), &env); } @@ -675,7 +674,7 @@ class any_write_sink_test capy::test::blocking_context bctx; auto ex = bctx.get_executor(); - io_env env{executor_ref(ex), {}}; + await_context env{executor_ref(ex), {}}; aw.await_suspend( std::noop_coroutine(), &env); @@ -699,7 +698,7 @@ class any_write_sink_test capy::test::blocking_context bctx; auto ex = bctx.get_executor(); - io_env env{executor_ref(ex), {}}; + await_context env{executor_ref(ex), {}}; aw.await_suspend(std::noop_coroutine(), &env); any_write_sink empty; diff --git a/test/unit/json/json_sink.cpp b/test/unit/json/json_sink.cpp index 409af475..cf752404 100644 --- a/test/unit/json/json_sink.cpp +++ b/test/unit/json/json_sink.cpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include diff --git a/test/unit/test/buffer_sink.cpp b/test/unit/test/buffer_sink.cpp index 04cc433a..6013a7b2 100644 --- a/test/unit/test/buffer_sink.cpp +++ b/test/unit/test/buffer_sink.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include "test_helpers.hpp" diff --git a/test/unit/test/buffer_source.cpp b/test/unit/test/buffer_source.cpp index a374d860..207b1ac3 100644 --- a/test/unit/test/buffer_source.cpp +++ b/test/unit/test/buffer_source.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include #include "test_helpers.hpp" diff --git a/test/unit/test/read_source.cpp b/test/unit/test/read_source.cpp index c3bac6da..538c3509 100644 --- a/test/unit/test/read_source.cpp +++ b/test/unit/test/read_source.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include "test_helpers.hpp" diff --git a/test/unit/test/write_sink.cpp b/test/unit/test/write_sink.cpp index 5f06539f..358b34cc 100644 --- a/test/unit/test/write_sink.cpp +++ b/test/unit/test/write_sink.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include "test_helpers.hpp"