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