MCPcopy Create free account
hub / github.com/OpenMW/openmw / removeUnreferencedObjectsInCache

Method removeUnreferencedObjectsInCache

components/resource/multiobjectcache.cpp:9–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7namespace Resource
8{
9 void MultiObjectCache::removeUnreferencedObjectsInCache()
10 {
11 std::vector<osg::ref_ptr<osg::Object>> objectsToRemove;
12 {
13 std::lock_guard<std::mutex> lock(_objectCacheMutex);
14
15 // Remove unreferenced entries from object cache
16 ObjectCacheMap::iterator oitr = _objectCache.begin();
17 while (oitr != _objectCache.end())
18 {
19 if (oitr->second->referenceCount() <= 1)
20 {
21 objectsToRemove.push_back(oitr->second);
22 _objectCache.erase(oitr++);
23 ++mExpired;
24 }
25 else
26 {
27 ++oitr;
28 }
29 }
30 }
31
32 // note, actual unref happens outside of the lock
33 objectsToRemove.clear();
34 }
35
36 void MultiObjectCache::clear()
37 {

Callers 1

updateCacheMethod · 0.80

Calls 4

beginMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected