mirror of
https://github.com/qicosmos/rest_rpc.git
synced 2026-08-29 08:34:47 +08:00
fix for msvc
This commit is contained in:
@@ -174,6 +174,7 @@ private:
|
||||
}
|
||||
}
|
||||
}
|
||||
co_return;
|
||||
}
|
||||
|
||||
template <typename R, typename Arg, typename F, typename Self>
|
||||
@@ -213,6 +214,7 @@ private:
|
||||
}
|
||||
}
|
||||
}
|
||||
co_return;
|
||||
}
|
||||
|
||||
template <typename R, typename Args, typename F, typename Self>
|
||||
@@ -266,6 +268,7 @@ private:
|
||||
}
|
||||
}
|
||||
}
|
||||
co_return;
|
||||
}
|
||||
|
||||
std::unordered_map<uint32_t, std::function<asio::awaitable<void>(
|
||||
|
||||
+13
-12
@@ -40,6 +40,17 @@ int round1(int i) { return i; }
|
||||
|
||||
std::string_view echo_sv(std::string_view str) { return str; }
|
||||
|
||||
template<auto func>
|
||||
asio::awaitable<void> response(auto ctx) {
|
||||
auto ec = co_await ctx.response<func>("test");
|
||||
if (ec) {
|
||||
REST_LOG_ERROR << "response error: " << ec.message();
|
||||
}
|
||||
ec = co_await ctx.response<func>("test");
|
||||
REST_LOG_ERROR << ec.message();
|
||||
CHECK(ec);
|
||||
}
|
||||
|
||||
std::string_view delay_response(std::string_view str) {
|
||||
auto &ctx = rpc_context::context();
|
||||
// set_delay before response in another thread
|
||||
@@ -52,18 +63,8 @@ std::string_view delay_response(std::string_view str) {
|
||||
// REST_LOG_ERROR << "response error: " << ec.message();
|
||||
// }
|
||||
auto executor = ctx.get_executor();
|
||||
auto coro = [ctx = std::move(ctx)]() mutable -> asio::awaitable<void> {
|
||||
auto ec = co_await ctx.response<delay_response>("test");
|
||||
if (ec) {
|
||||
REST_LOG_ERROR << "response error: " << ec.message();
|
||||
}
|
||||
ec = co_await ctx.response<delay_response>("test");
|
||||
REST_LOG_ERROR << ec.message();
|
||||
CHECK(ec);
|
||||
};
|
||||
|
||||
async_start(executor, std::move(coro));
|
||||
// asio::co_spawn(executor, std::move(coro), asio::detached);
|
||||
// async_start(executor, response<delay_response>(std::move(ctx)));
|
||||
asio::co_spawn(executor, response<delay_response>(std::move(ctx)), asio::detached);
|
||||
});
|
||||
thd.detach();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user