3 #include <CesiumUtility/Assert.h>
4 #include <CesiumUtility/ExtensibleObject.h>
5 #include <CesiumUtility/IDepotOwningAsset.h>
6 #include <CesiumUtility/Library.h>
11 template <
typename TAssetType,
typename TAssetKey>
class SharedAssetDepot;
83 ~
SharedAsset() { CESIUM_ASSERT(this->_referenceCount == 0); }
106 CesiumUtility::ExtensibleObject::operator=(rhs);
111 CesiumUtility::ExtensibleObject::operator=(std::move(rhs));
116 void addReference(
bool threadOwnsDepotLock)
const noexcept {
117 const int32_t prevReferences = this->_referenceCount++;
118 if (this->_pDepot && prevReferences <= 0) {
119 this->_pDepot->unmarkDeletionCandidate(
120 *
static_cast<const T*
>(
this),
121 threadOwnsDepotLock);
125 void releaseReference(
bool threadOwnsDepotLock)
const noexcept {
126 CESIUM_ASSERT(this->_referenceCount > 0);
127 const int32_t references = --this->_referenceCount;
128 if (references == 0) {
129 IDepotOwningAsset<T>* pDepot = this->_pDepot;
132 pDepot->markDeletionCandidate(
133 *
static_cast<const T*
>(
this),
134 threadOwnsDepotLock);
137 delete static_cast<const T*
>(
this);
142 mutable std::atomic<std::int32_t> _referenceCount{0};
143 IDepotOwningAsset<T>* _pDepot{
nullptr};
146 template <
typename TAssetType,
typename TAssetKey>
A depot for SharedAsset instances, which are potentially shared between multiple objects.
An asset that is potentially shared between multiple objects, such as an image shared between multipl...
SharedAsset(const SharedAsset &rhs)
SharedAsset & operator=(const SharedAsset &rhs)
void releaseReference() const noexcept
Removes a counted reference from this object. When the last reference is removed, this method will de...
void addReference() const noexcept
Adds a counted reference to this object. Use CesiumUtility::IntrusivePointer instead of calling this ...
const IDepotOwningAsset< T > * getDepot() const
Gets the shared asset depot that owns this asset, or nullptr if this asset is independent of an asset...
IDepotOwningAsset< T > * getDepot()
Gets the shared asset depot that owns this asset, or nullptr if this asset is independent of an asset...
SharedAsset(SharedAsset &&rhs)
Classes that support asynchronous operations.
Utility classes for Cesium.
The base class for objects that have extensions and extras.