0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-28 06:48:20 +02:00

ircd::ios: Add asio::defer() to interface.

This commit is contained in:
Jason Volk 2019-04-12 16:26:34 -07:00
parent 8c68a24e1f
commit 58c5ac7855
2 changed files with 28 additions and 7 deletions

View file

@ -54,8 +54,10 @@ namespace ircd::ios
const string_view &name(const handler &);
void dispatch(descriptor &, std::function<void ()>);
void defer(descriptor &, std::function<void ()>);
void post(descriptor &, std::function<void ()>);
void dispatch(std::function<void ()>);
void defer(std::function<void ()>);
void post(std::function<void ()>);
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;
}

View file

@ -70,6 +70,17 @@ ircd::ios::post(std::function<void ()> function)
post(descriptor, std::move(function));
}
void
ircd::ios::defer(std::function<void ()> function)
{
static descriptor descriptor
{
"ircd::ios defer"
};
defer(descriptor, std::move(function));
}
void
ircd::ios::dispatch(std::function<void ()> function)
{
@ -81,13 +92,6 @@ ircd::ios::dispatch(std::function<void ()> function)
dispatch(descriptor, std::move(function));
}
void
ircd::ios::post(descriptor &descriptor,
std::function<void ()> function)
{
boost::asio::post(get(), handle(descriptor, std::move(function)));
}
void
ircd::ios::dispatch(descriptor &descriptor,
std::function<void ()> 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<void ()> function)
{
boost::asio::defer(get(), handle(descriptor, std::move(function)));
}
void
ircd::ios::post(descriptor &descriptor,
std::function<void ()> function)
{
boost::asio::post(get(), handle(descriptor, std::move(function)));
}
boost::asio::io_context &
ircd::ios::get()
{