Skip to content

Commit

Permalink
ObjectsRegistry: added ProcessElements method
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMostDiligent committed Jan 26, 2024
1 parent 2c8faca commit 87100fb
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Common/interface/ObjectsRegistry.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2023 Diligent Graphics LLC
/* Copyright 2023-2024 Diligent Graphics LLC
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Expand Down Expand Up @@ -250,6 +250,20 @@ class ObjectsRegistry
PurgeUnguarded();
}

/// Processes each element in the cache with the specified handler.
template <typename HandlerType>
void ProcessElements(HandlerType&& Handler)
{
std::lock_guard<std::mutex> Guard{m_CacheMtx};
for (auto& Entry : m_Cache)
{
if (auto pObject = Entry.second->Lock())
{
Handler(Entry.first, *pObject);
}
}
}

private:
class ObjectWrapper
{
Expand Down

0 comments on commit 87100fb

Please sign in to comment.