Revert "libutil: allow graceful dropping of Pool::Handle"
This reverts commit 8075541d82d05347321d35b9934ccee5f82142f4.
Change-Id: I05fa6a9de1308a4827a6557cf2807eb47ca64da6
This commit is contained in:
parent
821ad98beb
commit
c77b6e1fdd
|
@ -108,19 +108,6 @@ public:
|
||||||
|
|
||||||
Handle(Pool & pool, std::shared_ptr<R> r) : pool(pool), r(r) { }
|
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:
|
public:
|
||||||
Handle(Handle && h) : pool(h.pool), r(h.r) { h.r.reset(); }
|
Handle(Handle && h) : pool(h.pool), r(h.r) { h.r.reset(); }
|
||||||
|
|
||||||
|
@ -128,13 +115,15 @@ public:
|
||||||
|
|
||||||
~Handle()
|
~Handle()
|
||||||
{
|
{
|
||||||
if (r)
|
if (!r) return;
|
||||||
drop(std::uncaught_exceptions() == 0);
|
{
|
||||||
}
|
auto state_(pool.state.lock());
|
||||||
|
if (!std::uncaught_exceptions())
|
||||||
void release()
|
state_->idle.push_back(ref<R>(r));
|
||||||
{
|
assert(state_->inUse);
|
||||||
drop(true);
|
state_->inUse--;
|
||||||
|
}
|
||||||
|
pool.wakeup.notify_one();
|
||||||
}
|
}
|
||||||
|
|
||||||
R * operator -> () { return &*r; }
|
R * operator -> () { return &*r; }
|
||||||
|
|
Loading…
Reference in a new issue