aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-04-05 03:51:52 +0200
committereldritch horrors <pennae@lix.systems>2024-04-05 20:13:02 +0000
commitc77b6e1fdd2ecacaa044b84dc89e89565337ddaa (patch)
tree4c057f9a7071457f450d9ba5e8fcf0767e142371
parent821ad98beb1a915ea7a456c274bcfca9e059ba91 (diff)
Revert "libutil: allow graceful dropping of Pool::Handle"
This reverts commit 8075541d82d05347321d35b9934ccee5f82142f4. Change-Id: I05fa6a9de1308a4827a6557cf2807eb47ca64da6
-rw-r--r--src/libutil/pool.hh29
1 files 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> 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>(r));
+ assert(state_->inUse);
+ state_->inUse--;
+ }
+ pool.wakeup.notify_one();
}
R * operator -> () { return &*r; }