pool: add clear

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman 2024-01-19 14:44:37 +01:00
parent 8839c80fec
commit 528ea5fffe

View File

@ -87,5 +87,18 @@ namespace stdex
const std::lock_guard<spinlock> guard(ne.lock);
ne.list.push_front(std::move(r));
}
///
/// Removes all items from the pool
///
void clear()
{
const std::lock_guard<std::mutex> guard_m(m_mutex);
for (auto& ne : m_available) {
const std::lock_guard<spinlock> guard_l(ne.second.lock);
while (!ne.second.list.empty())
ne.second.list.pop_front();
}
}
};
}