pool: add clear
Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
8839c80fec
commit
528ea5fffe
@ -87,5 +87,18 @@ namespace stdex
|
|||||||
const std::lock_guard<spinlock> guard(ne.lock);
|
const std::lock_guard<spinlock> guard(ne.lock);
|
||||||
ne.list.push_front(std::move(r));
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user