From 58c5ac7855d728a5e0d93ccee028e2de4bd5f6e7 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Fri, 12 Apr 2019 16:26:34 -0700 Subject: [PATCH] ircd::ios: Add asio::defer() to interface. --- include/ircd/ios.h | 3 +++ ircd/ios.cc | 32 +++++++++++++++++++++++++------- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/include/ircd/ios.h b/include/ircd/ios.h index 8256cecd0..f3f0e8a56 100644 --- a/include/ircd/ios.h +++ b/include/ircd/ios.h @@ -54,8 +54,10 @@ namespace ircd::ios const string_view &name(const handler &); void dispatch(descriptor &, std::function); + void defer(descriptor &, std::function); void post(descriptor &, std::function); void dispatch(std::function); + void defer(std::function); void post(std::function); void init(asio::io_context &user); } @@ -65,6 +67,7 @@ namespace ircd using ios::assert_main_thread; using ios::is_main_thread; using ios::dispatch; + using ios::defer; using ios::post; } diff --git a/ircd/ios.cc b/ircd/ios.cc index aae7aaf17..6f549dd2d 100644 --- a/ircd/ios.cc +++ b/ircd/ios.cc @@ -70,6 +70,17 @@ ircd::ios::post(std::function function) post(descriptor, std::move(function)); } +void +ircd::ios::defer(std::function function) +{ + static descriptor descriptor + { + "ircd::ios defer" + }; + + defer(descriptor, std::move(function)); +} + void ircd::ios::dispatch(std::function function) { @@ -81,13 +92,6 @@ ircd::ios::dispatch(std::function function) dispatch(descriptor, std::move(function)); } -void -ircd::ios::post(descriptor &descriptor, - std::function function) -{ - boost::asio::post(get(), handle(descriptor, std::move(function))); -} - void ircd::ios::dispatch(descriptor &descriptor, std::function function) @@ -95,6 +99,20 @@ ircd::ios::dispatch(descriptor &descriptor, boost::asio::dispatch(get(), handle(descriptor, std::move(function))); } +void +ircd::ios::defer(descriptor &descriptor, + std::function function) +{ + boost::asio::defer(get(), handle(descriptor, std::move(function))); +} + +void +ircd::ios::post(descriptor &descriptor, + std::function function) +{ + boost::asio::post(get(), handle(descriptor, std::move(function))); +} + boost::asio::io_context & ircd::ios::get() {