Skip to content

Commit

Permalink
Move AssetEntry implementation, too.
Browse files Browse the repository at this point in the history
  • Loading branch information
kring committed Dec 23, 2024
1 parent dc7958c commit 126171b
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions CesiumAsync/include/CesiumAsync/SharedAssetDepot.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,19 +207,7 @@ class CESIUMASYNC_API SharedAssetDepot
*/
CesiumUtility::DoublyLinkedListPointers<AssetEntry> deletionListPointers;

CesiumUtility::ResultPointer<TAssetType> toResultUnderLock() const {
// This method is called while the calling thread already owns the depot
// mutex. So we must take care not to lock it again, which could happen if
// the asset is currently unreferenced and we naively create an
// IntrusivePointer for it.
CesiumUtility::IntrusivePointer<TAssetType> p = nullptr;
if (pAsset) {
pAsset->addReference(true);
p = pAsset.get();
pAsset->releaseReference(true);
}
return CesiumUtility::ResultPointer<TAssetType>(p, errorsAndWarnings);
}
CesiumUtility::ResultPointer<TAssetType> toResultUnderLock() const;
};

// Maps asset keys to AssetEntry instances. This collection owns the asset
Expand Down Expand Up @@ -510,4 +498,20 @@ void SharedAssetDepot<TAssetType, TAssetKey>::unmarkDeletionCandidateUnderLock(
this->_pKeepAlive = this;
}

template <typename TAssetType, typename TAssetKey>
CesiumUtility::ResultPointer<TAssetType>
SharedAssetDepot<TAssetType, TAssetKey>::AssetEntry::toResultUnderLock() const {
// This method is called while the calling thread already owns the depot
// mutex. So we must take care not to lock it again, which could happen if
// the asset is currently unreferenced and we naively create an
// IntrusivePointer for it.
CesiumUtility::IntrusivePointer<TAssetType> p = nullptr;
if (pAsset) {
pAsset->addReference(true);
p = pAsset.get();
pAsset->releaseReference(true);
}
return CesiumUtility::ResultPointer<TAssetType>(p, errorsAndWarnings);
}

} // namespace CesiumAsync

0 comments on commit 126171b

Please sign in to comment.