Skip to content

Commit 87100fb

Browse files
ObjectsRegistry: added ProcessElements method
1 parent 2c8faca commit 87100fb

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

Common/interface/ObjectsRegistry.hpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2023 Diligent Graphics LLC
1+
/* Copyright 2023-2024 Diligent Graphics LLC
22
33
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
44
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
@@ -250,6 +250,20 @@ class ObjectsRegistry
250250
PurgeUnguarded();
251251
}
252252

253+
/// Processes each element in the cache with the specified handler.
254+
template <typename HandlerType>
255+
void ProcessElements(HandlerType&& Handler)
256+
{
257+
std::lock_guard<std::mutex> Guard{m_CacheMtx};
258+
for (auto& Entry : m_Cache)
259+
{
260+
if (auto pObject = Entry.second->Lock())
261+
{
262+
Handler(Entry.first, *pObject);
263+
}
264+
}
265+
}
266+
253267
private:
254268
class ObjectWrapper
255269
{

0 commit comments

Comments
 (0)