Copy set of shared ptrs

This commit is contained in:
Anonymous-275 2021-03-31 00:36:15 +03:00
parent f323d50e34
commit 50549f3d1a

View File

@ -48,7 +48,12 @@ std::weak_ptr<TClient> TServer::InsertNewClient() {
}
void TServer::ForEachClient(const std::function<bool(std::weak_ptr<TClient>)>& Fn) {
for (auto& Client : mClients) {
decltype(mClients) Clients;
{
ReadLock lock(mClientsMutex);
Clients = mClients;
}
for (auto& Client : Clients) {
if (!Fn(Client)) {
break;
}