@@ -260,13 +260,11 @@ inline async_simple::coro::Lazy<std::error_code> async_handshake(
260260#endif
261261class period_timer : public asio ::steady_timer {
262262 public:
263+ using asio::steady_timer::steady_timer;
263264 template <typename T>
264265 period_timer (coro_io::ExecutorWrapper<T> *executor)
265266 : asio::steady_timer(executor->get_asio_executor ()) {}
266- template <typename executor_t , typename Rep, typename Period>
267- period_timer (const executor_t &executor,
268- const std::chrono::duration<Rep, Period> &timeout_duration)
269- : asio::steady_timer(executor, timeout_duration) {}
267+
270268 async_simple::coro::Lazy<bool > async_await () noexcept {
271269 callback_awaitor<bool > awaitor;
272270
@@ -297,10 +295,10 @@ inline async_simple::coro::Lazy<void> sleep_for(const Duration &d) {
297295 }
298296}
299297
300- template <typename R, typename Func>
298+ template <typename R, typename Func, typename Executor >
301299struct post_helper {
302300 void operator ()(auto handler) const {
303- asio::dispatch (e-> get_asio_executor () , [this , handler]() {
301+ asio::dispatch (e, [this , handler]() {
304302 try {
305303 if constexpr (std::is_same_v<R, async_simple::Try<void >>) {
306304 func ();
@@ -317,24 +315,30 @@ struct post_helper {
317315 }
318316 });
319317 }
320- coro_io::ExecutorWrapper<> * e;
318+ Executor e;
321319 Func func;
322320};
323321
324- template <typename Func>
322+ template <typename Func, typename Executor >
325323inline async_simple::coro::Lazy<
326324 async_simple::Try<typename util::function_traits<Func>::return_type>>
327- post (Func func,
328- coro_io::ExecutorWrapper<> *e = coro_io::get_global_block_executor()) {
325+ post (Func func, Executor executor) {
329326 using R =
330327 async_simple::Try<typename util::function_traits<Func>::return_type>;
331328
332329 callback_awaitor<R> awaitor;
333-
334- post_helper<R, Func> helper{e, std::move (func)};
330+ post_helper<R, Func, Executor> helper{executor, std::move (func)};
335331 co_return co_await awaitor.await_resume (helper);
336332}
337333
334+ template <typename Func>
335+ inline async_simple::coro::Lazy<
336+ async_simple::Try<typename util::function_traits<Func>::return_type>>
337+ post (Func func,
338+ coro_io::ExecutorWrapper<> *e = coro_io::get_global_block_executor()) {
339+ co_return co_await post (std::move (func), e->get_asio_executor ());
340+ }
341+
338342template <typename R>
339343struct coro_channel
340344 : public asio::experimental::channel<void (std::error_code, R)> {
0 commit comments