From 5698637dd6c01cfe3c06f13fede2b1aa6ed9a314 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Tue, 18 Sep 2018 16:45:04 -0700 Subject: [PATCH] ircd::ctx::pool: Use ctx::queue for pool's queue. --- include/ircd/ctx/pool.h | 5 ++--- ircd/ctx.cc | 13 +++++-------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/include/ircd/ctx/pool.h b/include/ircd/ctx/pool.h index 29ba557e1..0d191dc2d 100644 --- a/include/ircd/ctx/pool.h +++ b/include/ircd/ctx/pool.h @@ -25,8 +25,7 @@ struct ircd::ctx::pool size_t stack_size; size_t running; size_t working; - struct dock dock; - std::deque queue; + queue q; std::vector ctxs; void next(); @@ -35,7 +34,7 @@ struct ircd::ctx::pool public: // indicators auto size() const { return ctxs.size(); } - auto queued() const { return queue.size(); } + auto queued() const { return q.size(); } auto active() const { return working; } auto avail() const { return running - working; } auto pending() const { return active() + queued(); } diff --git a/ircd/ctx.cc b/ircd/ctx.cc index 63ee5da83..f6efadb25 100644 --- a/ircd/ctx.cc +++ b/ircd/ctx.cc @@ -1024,14 +1024,13 @@ noexcept join(); assert(ctxs.empty()); - assert(queue.empty()); + assert(q.empty()); } void ircd::ctx::pool::operator()(closure closure) { - queue.push_back(std::move(closure)); - dock.notify(); + q.emplace(std::move(closure)); } void @@ -1119,10 +1118,10 @@ void ircd::ctx::pool::next() try { - dock.wait([this] + const auto func { - return !queue.empty(); - }); + std::move(q.pop()) + }; ++working; const unwind avail([this] @@ -1130,8 +1129,6 @@ try --working; }); - const auto func(std::move(queue.front())); - queue.pop_front(); func(); } catch(const interrupted &e)