From be7a20d39adbe2ad3d935a6e6e0e7ce094a394f2 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Tue, 18 Sep 2018 21:35:27 -0700 Subject: [PATCH] ircd::ctx: Move any renotifying to the ctx::dock itself. --- include/ircd/ctx/dock.h | 30 +++++++++++++++++++++++++++ include/ircd/ctx/queue.h | 45 ---------------------------------------- 2 files changed, 30 insertions(+), 45 deletions(-) diff --git a/include/ircd/ctx/dock.h b/include/ircd/ctx/dock.h index bc8b7302c..1055d5620 100644 --- a/include/ircd/ctx/dock.h +++ b/include/ircd/ctx/dock.h @@ -87,6 +87,11 @@ inline void ircd::ctx::dock::wait() { assert(current); + const unwind::exceptional renotify{[this] + { + notify_one(); + }}; + const unwind remove{[this] { q.remove(current); @@ -104,6 +109,11 @@ ircd::ctx::dock::wait(predicate&& pred) return; assert(current); + const unwind::exceptional renotify{[this] + { + notify_one(); + }}; + const unwind remove{[this] { q.remove(current); @@ -124,6 +134,11 @@ ircd::ctx::dock::wait_for(const duration &dur) static const duration zero(0); assert(current); + const unwind::exceptional renotify{[this] + { + notify_one(); + }}; + const unwind remove{[this] { q.remove(current); @@ -146,6 +161,11 @@ ircd::ctx::dock::wait_for(const duration &dur, return true; assert(current); + const unwind::exceptional renotify{[this] + { + notify_one(); + }}; + const unwind remove{[this] { q.remove(current); @@ -173,6 +193,11 @@ bool ircd::ctx::dock::wait_until(time_point&& tp) { assert(current); + const unwind::exceptional renotify{[this] + { + notify_one(); + }}; + const unwind remove{[this] { q.remove(current); @@ -193,6 +218,11 @@ ircd::ctx::dock::wait_until(time_point&& tp, return true; assert(current); + const unwind::exceptional renotify{[this] + { + notify_one(); + }}; + const unwind remove{[this] { q.remove(current); diff --git a/include/ircd/ctx/queue.h b/include/ircd/ctx/queue.h index 2139dc74a..874055552 100644 --- a/include/ircd/ctx/queue.h +++ b/include/ircd/ctx/queue.h @@ -76,7 +76,6 @@ ircd::ctx::queue::emplace(args&&... a) template T ircd::ctx::queue::pop() -try { dock.wait([this] { @@ -92,26 +91,11 @@ try auto &ret(q.front()); return std::move(ret); } -catch(const interrupted &) -{ - if(!q.empty()) - dock.notify(); - - throw; -} -catch(const terminated &) -{ - if(!q.empty()) - dock.notify(); - - throw; -} template template T ircd::ctx::queue::pop_for(const duration &dur) -try { const bool ready { @@ -133,26 +117,11 @@ try auto &ret(q.front()); return std::move(ret); } -catch(const interrupted &) -{ - if(!q.empty()) - dock.notify(); - - throw; -} -catch(const terminated &) -{ - if(!q.empty()) - dock.notify(); - - throw; -} template template T ircd::ctx::queue::pop_until(time_point&& tp) -try { const bool ready { @@ -174,17 +143,3 @@ try auto &ret(q.front()); return std::move(ret); } -catch(const interrupted &) -{ - if(!q.empty()) - dock.notify(); - - throw; -} -catch(const terminated &) -{ - if(!q.empty()) - dock.notify(); - - throw; -}