From c9c280c864b001e6232893a83cd13a9da56bc049 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Fri, 28 Dec 2018 12:42:08 -0800 Subject: [PATCH] ircd::ctx: Simplify queue interface; remove access to dock. --- include/ircd/ctx/queue.h | 32 +++++++------------------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/include/ircd/ctx/queue.h b/include/ircd/ctx/queue.h index 825f4fa41..0c7eb29de 100644 --- a/include/ircd/ctx/queue.h +++ b/include/ircd/ctx/queue.h @@ -19,14 +19,11 @@ namespace ircd::ctx template class ircd::ctx::queue { - struct dock dock; + dock d; std::queue q; size_t w {0}; public: - explicit operator const struct dock &() const; - explicit operator struct dock &(); - size_t empty() const; size_t size() const; size_t waiting() const; @@ -58,7 +55,7 @@ ircd::ctx::queue::push(T&& t) noexcept { q.push(std::forward(t)); - dock.notify(); + d.notify(); } template @@ -66,7 +63,7 @@ void ircd::ctx::queue::push(const T &t) { q.push(t); - dock.notify(); + d.notify(); } template @@ -75,7 +72,7 @@ void ircd::ctx::queue::emplace(args&&... a) { q.emplace(std::forward(a)...); - dock.notify(); + d.notify(); } template @@ -88,7 +85,7 @@ ircd::ctx::queue::pop() --w; }}; - dock.wait([this] + d.wait([this] { return !q.empty(); }); @@ -112,7 +109,7 @@ ircd::ctx::queue::pop_for(const duration &dur) const bool ready { - dock.wait_for(dur, [this] + d.wait_for(dur, [this] { return !q.empty(); }) @@ -140,7 +137,7 @@ ircd::ctx::queue::pop_until(time_point&& tp) const bool ready { - dock.wait_until(tp, [this] + d.wait_until(tp, [this] { return !q.empty(); }) @@ -178,18 +175,3 @@ const { return q.empty(); } - -template -ircd::ctx::queue::operator -struct dock &() -{ - return dock; -} - -template -ircd::ctx::queue::operator -const struct dock &() -const -{ - return dock; -}