libutil: remove Pool::flushBad
this was never actually used, and bad design in the first place—why should a bad resource be put back into the idle pool? just drop it. Change-Id: Idab8774bee19dadae0209d404c4fb86dd4aeba1e
This commit is contained in:
parent
fe7e924026
commit
4556892c17
4 changed files with 0 additions and 32 deletions
|
@ -940,11 +940,6 @@ std::optional<TrustedFlag> RemoteStore::isTrustedClient()
|
|||
return conn->remoteTrustsUs;
|
||||
}
|
||||
|
||||
void RemoteStore::flushBadConnections()
|
||||
{
|
||||
connections->flushBad();
|
||||
}
|
||||
|
||||
|
||||
RemoteStore::Connection::~Connection()
|
||||
{
|
||||
|
|
|
@ -161,8 +161,6 @@ public:
|
|||
|
||||
std::optional<TrustedFlag> isTrustedClient() override;
|
||||
|
||||
void flushBadConnections();
|
||||
|
||||
struct Connection;
|
||||
|
||||
ref<Connection> openConnectionWrapper();
|
||||
|
|
|
@ -184,16 +184,6 @@ public:
|
|||
{
|
||||
return state.lock()->max;
|
||||
}
|
||||
|
||||
void flushBad()
|
||||
{
|
||||
auto state_(state.lock());
|
||||
std::vector<ref<R>> left;
|
||||
for (auto & p : state_->idle)
|
||||
if (validator(p))
|
||||
left.push_back(p);
|
||||
std::swap(state_->idle, left);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -65,21 +65,6 @@ namespace nix {
|
|||
ASSERT_EQ(pool.capacity(), 0);
|
||||
}
|
||||
|
||||
TEST(Pool, flushBadDropsOutOfScopeResources) {
|
||||
auto isGood = [](const ref<TestResource> & r) { return false; };
|
||||
auto createResource = []() { return make_ref<TestResource>(); };
|
||||
|
||||
Pool<TestResource> pool = Pool<TestResource>((size_t)1, createResource, isGood);
|
||||
|
||||
{
|
||||
auto _r = pool.get();
|
||||
ASSERT_EQ(pool.count(), 1);
|
||||
}
|
||||
|
||||
pool.flushBad();
|
||||
ASSERT_EQ(pool.count(), 0);
|
||||
}
|
||||
|
||||
// Test that the resources we allocate are being reused when they are still good.
|
||||
TEST(Pool, reuseResource) {
|
||||
auto isGood = [](const ref<TestResource> & r) { return true; };
|
||||
|
|
Loading…
Reference in a new issue