From c77b6e1fdd2ecacaa044b84dc89e89565337ddaa Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Fri, 5 Apr 2024 03:51:52 +0200 Subject: [PATCH] Revert "libutil: allow graceful dropping of Pool::Handle" This reverts commit 8075541d82d05347321d35b9934ccee5f82142f4. Change-Id: I05fa6a9de1308a4827a6557cf2807eb47ca64da6 --- src/libutil/pool.hh | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/src/libutil/pool.hh b/src/libutil/pool.hh index bc71083e9..2f6d30130 100644 --- a/src/libutil/pool.hh +++ b/src/libutil/pool.hh @@ -108,19 +108,6 @@ public: Handle(Pool & pool, std::shared_ptr r) : pool(pool), r(r) { } - void drop(bool stillValid) - { - { - auto state_(pool.state.lock()); - if (stillValid) - state_->idle.emplace_back(std::move(r)); - assert(state_->inUse); - state_->inUse--; - } - pool.wakeup.notify_one(); - r = nullptr; - } - public: Handle(Handle && h) : pool(h.pool), r(h.r) { h.r.reset(); } @@ -128,13 +115,15 @@ public: ~Handle() { - if (r) - drop(std::uncaught_exceptions() == 0); - } - - void release() - { - drop(true); + if (!r) return; + { + auto state_(pool.state.lock()); + if (!std::uncaught_exceptions()) + state_->idle.push_back(ref(r)); + assert(state_->inUse); + state_->inUse--; + } + pool.wakeup.notify_one(); } R * operator -> () { return &*r; }