From 4fa7ad928649f4592125ca05a2089b1423c48816 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Mon, 8 Jan 2018 12:40:09 -0800 Subject: [PATCH] ircd::ctx: Add use_future_t; minor cleanup. --- include/ircd/ctx/ctx.h | 15 ++++++++++----- include/ircd/ctx/future.h | 2 ++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/include/ircd/ctx/ctx.h b/include/ircd/ctx/ctx.h index be3bf1134..fb2b74c56 100644 --- a/include/ircd/ctx/ctx.h +++ b/include/ircd/ctx/ctx.h @@ -48,15 +48,17 @@ /// namespace ircd::ctx { - IRCD_EXCEPTION(ircd::error, error) - IRCD_EXCEPTION(error, interrupted) - IRCD_EXCEPTION(error, timeout) - using std::chrono::steady_clock; using time_point = steady_clock::time_point; struct ctx; + IRCD_EXCEPTION(ircd::error, error) + IRCD_EXCEPTION(error, interrupted) + IRCD_EXCEPTION(error, timeout) + + IRCD_OVERLOAD(threadsafe) + const uint64_t &id(const ctx &); // Unique ID for context string_view name(const ctx &); // User's optional label for context const int64_t ¬es(const ctx &); // Peeks at internal semaphore count @@ -64,7 +66,6 @@ namespace ircd::ctx bool finished(const ctx &); // Context function returned (or exception). bool started(const ctx &); // Context was ever entered. - IRCD_OVERLOAD(threadsafe) void interrupt(ctx &); // Interrupt the context for termination. void signal(ctx &, std::function); // Post function to context strand void notify(ctx &, threadsafe_t); // Notify context with threadsafety. @@ -124,6 +125,7 @@ namespace ircd::ctx { inline namespace this_ctx #include "ole.h" #include "fault.h" +// Exports to ircd:: namespace ircd { //using yield = boost::asio::yield_context; @@ -133,6 +135,9 @@ namespace ircd using ctx::promise; using ctx::future; + + using ctx::use_future_t; + using ctx::use_future; } /// An instance of critical_assertion detects an attempt to context switch. diff --git a/include/ircd/ctx/future.h b/include/ircd/ctx/future.h index 9a69efb82..28e827806 100644 --- a/include/ircd/ctx/future.h +++ b/include/ircd/ctx/future.h @@ -24,6 +24,8 @@ namespace ircd::ctx { + IRCD_OVERLOAD(use_future) + template class future; template<> class future; template struct scoped_future;