From 6e97a72c5095ccb7979e01d6361f7563c38b4866 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sat, 13 Jul 2019 14:53:52 -0700 Subject: [PATCH] ircd::ctx::ole: Minor interface reorg. --- include/ircd/ctx/ole.h | 16 ++++++++++------ ircd/ctx_ole.cc | 15 +++++++-------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/include/ircd/ctx/ole.h b/include/ircd/ctx/ole.h index d11738e34..94903d9ce 100644 --- a/include/ircd/ctx/ole.h +++ b/include/ircd/ctx/ole.h @@ -20,11 +20,7 @@ namespace ircd::ctx::ole { struct init; - struct opts; - struct control; - using closure = std::function; - - void offload(const opts &, const closure &); + struct offload; } namespace ircd::ctx @@ -32,7 +28,15 @@ namespace ircd::ctx using ole::offload; } -struct ircd::ctx::ole::opts +struct ircd::ctx::offload +{ + struct opts; + using closure = std::function; + + offload(const opts &, const closure &); +}; + +struct ircd::ctx::ole::offload::opts { /// Optionally give this offload task a name for any tasklist. string_view name; diff --git a/ircd/ctx_ole.cc b/ircd/ctx_ole.cc index a728a9bb7..d92d1fc99 100644 --- a/ircd/ctx_ole.cc +++ b/ircd/ctx_ole.cc @@ -18,11 +18,11 @@ namespace ircd::ctx::ole std::mutex mutex; std::condition_variable cond; bool termination; - std::deque queue; + std::deque queue; std::vector threads; - closure pop(); - void push(closure &&); + offload::closure pop(); + void push(offload::closure &&); void worker() noexcept; } @@ -51,9 +51,8 @@ noexcept }); } -void -ircd::ctx::ole::offload(const opts &opts, - const closure &func) +ircd::ctx::ole::offload::offload(const opts &opts, + const closure &func) { assert(opts.concurrency == 1); // not yet implemented @@ -105,7 +104,7 @@ ircd::ctx::ole::offload(const opts &opts, std::rethrow_exception(eptr); } void -ircd::ctx::ole::push(closure &&func) +ircd::ctx::ole::push(offload::closure &&func) { if(unlikely(threads.size() < size_t(thread_max))) threads.emplace_back(&worker); @@ -141,7 +140,7 @@ catch(const interrupted &) cond.notify_all(); } -ircd::ctx::ole::closure +ircd::ctx::ole::offload::closure ircd::ctx::ole::pop() { std::unique_lock lock(mutex);