From 126171b45143bd966d303cf359f66cfab52e03f0 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Mon, 23 Dec 2024 13:11:49 +1100 Subject: [PATCH] Move AssetEntry implementation, too. --- .../include/CesiumAsync/SharedAssetDepot.h | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/CesiumAsync/include/CesiumAsync/SharedAssetDepot.h b/CesiumAsync/include/CesiumAsync/SharedAssetDepot.h index e5e7e87b0..c74dbf727 100644 --- a/CesiumAsync/include/CesiumAsync/SharedAssetDepot.h +++ b/CesiumAsync/include/CesiumAsync/SharedAssetDepot.h @@ -207,19 +207,7 @@ class CESIUMASYNC_API SharedAssetDepot */ CesiumUtility::DoublyLinkedListPointers deletionListPointers; - CesiumUtility::ResultPointer 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 p = nullptr; - if (pAsset) { - pAsset->addReference(true); - p = pAsset.get(); - pAsset->releaseReference(true); - } - return CesiumUtility::ResultPointer(p, errorsAndWarnings); - } + CesiumUtility::ResultPointer toResultUnderLock() const; }; // Maps asset keys to AssetEntry instances. This collection owns the asset @@ -510,4 +498,20 @@ void SharedAssetDepot::unmarkDeletionCandidateUnderLock( this->_pKeepAlive = this; } +template +CesiumUtility::ResultPointer +SharedAssetDepot::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 p = nullptr; + if (pAsset) { + pAsset->addReference(true); + p = pAsset.get(); + pAsset->releaseReference(true); + } + return CesiumUtility::ResultPointer(p, errorsAndWarnings); +} + } // namespace CesiumAsync