mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-08-03 15:27:13 -04:00
Restore some omitted object cache remarks that seemed useful
This commit is contained in:
parent
a00e5ec828
commit
6d74a4607c
@ -56,20 +56,22 @@ namespace Resource
|
||||
/*
|
||||
* @brief Updates usage timestamps and removes expired items
|
||||
*
|
||||
* Updates the lastUsage timestamp of cached items that have external references.
|
||||
* Updates the lastUsage timestamp of cached non-nullptr items that have external references.
|
||||
* Initializes lastUsage timestamp for new items.
|
||||
* Removes items that haven't been referenced for longer than expiryDelay.
|
||||
*
|
||||
* \note
|
||||
* Last usage might be updated from other places so nullptr items
|
||||
* that are not referenced elsewhere are not always removed.
|
||||
*
|
||||
* @param referenceTime the timestamp indicating when the item was most recently used
|
||||
* @param expiryDelay the delay after which the cache entry for an item expires
|
||||
*/
|
||||
void update(double referenceTime, double expiryDelay)
|
||||
{
|
||||
std::vector<osg::ref_ptr<osg::Object>> objectsToRemove;
|
||||
|
||||
{
|
||||
const double expiryTime = referenceTime - expiryDelay;
|
||||
|
||||
std::lock_guard<std::mutex> lock(mMutex);
|
||||
|
||||
std::erase_if(mItems, [&](auto& v) {
|
||||
@ -93,7 +95,6 @@ namespace Resource
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
// remove expired items from cache
|
||||
objectsToRemove.clear();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user