This commit is contained in:
qicosmos
2025-10-17 20:02:51 +08:00
parent b69ea77801
commit 9443222b5a
2 changed files with 15 additions and 2 deletions
+13
View File
@@ -1,4 +1,5 @@
#pragma once
#include "io_context_pool.hpp"
#include "traits.h"
#include "use_asio.hpp"
@@ -29,6 +30,18 @@ template <typename Coro> inline auto sync_wait(auto executor, Coro &&coro) {
return async_future(executor, std::forward<Coro>(coro)).get();
}
template <typename Coro> inline auto async_start(Coro &&coro) {
async_start(get_global_executor(), std::forward<Coro>(coro));
}
template <typename Coro> inline auto async_future(Coro &&coro) {
return async_future(get_global_executor(), std::forward<Coro>(coro));
}
template <typename Coro> inline auto sync_wait(Coro &&coro) {
return sync_wait(get_global_executor(), std::forward<Coro>(coro));
}
inline auto async_start(auto executor, auto &&coro, auto callback) {
using R = typename std::remove_cvref_t<decltype(coro)>::value_type;
if constexpr (std::is_void_v<R>) {