MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / cleanup

Method cleanup

source/base/StarAssets.cpp:618–638  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

616}
617
618void Assets::cleanup() {
619 MutexLocker assetsLocker(m_assetsMutex);
620
621 double time = Time::monotonicTime();
622
623 auto it = makeSMutableMapIterator(m_assetsCache);
624 while (it.hasNext()) {
625 auto pair = it.next();
626 // Don't clean up broken assets or queued assets.
627 if (pair.second && !m_queue.contains(pair.first)) {
628 double liveTime = time - pair.second->time;
629 if (liveTime > m_settings.assetTimeToLive) {
630 // If the asset should persist, just refresh the access time.
631 if (pair.second->shouldPersist())
632 pair.second->time = time;
633 else
634 it.remove();
635 }
636 }
637 }
638}
639
640bool Assets::AssetId::operator==(AssetId const& assetId) const {
641 return tie(type, path) == tie(assetId.type, assetId.path);

Callers

nothing calls this directly

Calls 6

makeSMutableMapIteratorFunction · 0.85
shouldPersistMethod · 0.80
hasNextMethod · 0.45
nextMethod · 0.45
containsMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected