diff --git a/include/boost/http/bcrypt.hpp b/include/boost/http/bcrypt.hpp index 78fc67bd..b78aaa62 100644 --- a/include/boost/http/bcrypt.hpp +++ b/include/boost/http/bcrypt.hpp @@ -41,6 +41,7 @@ #include #include +#include #include #include #include @@ -524,6 +525,7 @@ struct hash_async_op version ver_; result result_; std::exception_ptr ep_; + capy::continuation cont_; bool await_ready() const noexcept { @@ -534,21 +536,22 @@ struct hash_async_op std::coroutine_handle cont, capy::io_env const* env) { + cont_.h = cont; auto caller_ex = env->executor; auto& pool = capy::get_system_context(); auto sys_ex = pool.get_executor(); capy::run_async(sys_ex, - [this, cont, caller_ex] + [this, caller_ex] (result r) mutable { result_ = r; - caller_ex.dispatch(cont).resume(); + caller_ex.dispatch(cont_).resume(); }, - [this, cont, caller_ex] + [this, caller_ex] (std::exception_ptr ep) mutable { ep_ = ep; - caller_ex.dispatch(cont).resume(); + caller_ex.dispatch(cont_).resume(); } )(hash_task(password_, rounds_, ver_)); } @@ -567,6 +570,7 @@ struct compare_async_op hash_buf hash_str_; bool result_ = false; std::exception_ptr ep_; + capy::continuation cont_; bool await_ready() const noexcept { @@ -577,21 +581,22 @@ struct compare_async_op std::coroutine_handle cont, capy::io_env const* env) { + cont_.h = cont; auto caller_ex = env->executor; auto& pool = capy::get_system_context(); auto sys_ex = pool.get_executor(); capy::run_async(sys_ex, - [this, cont, caller_ex] + [this, caller_ex] (bool ok) mutable { result_ = ok; - caller_ex.dispatch(cont).resume(); + caller_ex.dispatch(cont_).resume(); }, - [this, cont, caller_ex] + [this, caller_ex] (std::exception_ptr ep) mutable { ep_ = ep; - caller_ex.dispatch(cont).resume(); + caller_ex.dispatch(cont_).resume(); } )(compare_task(password_, hash_str_)); } diff --git a/include/boost/http/json/json_sink.hpp b/include/boost/http/json/json_sink.hpp index 52844b24..ed58683e 100644 --- a/include/boost/http/json/json_sink.hpp +++ b/include/boost/http/json/json_sink.hpp @@ -60,7 +60,7 @@ class json_sink capy::immediate> write_impl(CB const& buffers, bool eof) { - system::error_code ec; + std::error_code ec; std::size_t total = 0; auto const end = capy::end(buffers); for(auto it = capy::begin(buffers); it != end; ++it) @@ -71,14 +71,14 @@ class json_sink buf.size(), ec); total += n; - if(ec.failed()) - return {ec, total}; + if(ec) + return capy::ready(ec, total); } if(eof) { parser_.finish(ec); - if(ec.failed()) - return {ec, total}; + if(ec) + return capy::ready(ec, total); } return capy::ready(total); } @@ -188,11 +188,11 @@ class json_sink capy::immediate> write_eof() { - system::error_code ec; + std::error_code ec; parser_.finish(ec); - if(ec.failed()) - return {ec}; - return {}; + if(ec) + return capy::ready(ec); + return capy::ready(); } /** Check if parsing is complete. diff --git a/test/unit/bcrypt.cpp b/test/unit/bcrypt.cpp index 058c580a..3a74f863 100644 --- a/test/unit/bcrypt.cpp +++ b/test/unit/bcrypt.cpp @@ -9,6 +9,7 @@ #include +#include #include #include #include @@ -50,14 +51,14 @@ struct test_executor void on_work_started() const noexcept {} void on_work_finished() const noexcept {} - std::coroutine_handle<> dispatch(std::coroutine_handle h) const + std::coroutine_handle<> dispatch(capy::continuation& c) const { - return h; + return c.h; } - void post(std::coroutine_handle h) const + void post(capy::continuation& c) const { - h.resume(); + c.h.resume(); } }; diff --git a/test/unit/json/json_sink.cpp b/test/unit/json/json_sink.cpp index 1f0003c3..ec09cff1 100644 --- a/test/unit/json/json_sink.cpp +++ b/test/unit/json/json_sink.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -67,16 +68,16 @@ struct test_executor void on_work_started() const noexcept {} void on_work_finished() const noexcept {} - std::coroutine_handle<> dispatch(std::coroutine_handle h) const + std::coroutine_handle<> dispatch(capy::continuation& c) const { if(dispatch_count_) ++(*dispatch_count_); - return h; + return c.h; } - void post(std::coroutine_handle h) const + void post(capy::continuation& c) const { - h.resume(); + c.h.resume(); } };