cesium-native 0.43.0
|
A depot for CesiumUtility::SharedAsset
instances, which are potentially shared between multiple objects.
More...
#include <CesiumAsync/SharedAssetDepot.h>
Public Types | |
using | FactorySignature |
Signature for the callback function that will be called to fetch and create a new instance of TAssetType if one with the given key doesn't already exist in the depot. | |
Public Member Functions | |
SharedAssetDepot (std::function< FactorySignature > factory) | |
Creates a new SharedAssetDepot using the given factory callback to load new assets. | |
SharedFuture< CesiumUtility::ResultPointer< TAssetType > > | getOrCreate (const AsyncSystem &asyncSystem, const std::shared_ptr< IAssetAccessor > &pAssetAccessor, const TAssetKey &assetKey) |
Gets an asset from the depot if it already exists, or creates it using the depot's factory if it does not. | |
size_t | getAssetCount () const |
Returns the total number of distinct assets contained in this depot, including both active and inactive assets. | |
size_t | getActiveAssetCount () const |
Gets the number of assets owned by this depot that are active, meaning that they are currently being used in one or more places. | |
size_t | getInactiveAssetCount () const |
Gets the number of assets owned by this depot that are inactive, meaning that they are not currently being used. | |
int64_t | getInactiveAssetTotalSizeBytes () const |
Gets the total bytes used by inactive (unused) assets owned by this depot. | |
Public Member Functions inherited from CesiumUtility::ReferenceCounted< T, isThreadSafe > | |
void | addReference () const |
Adds a counted reference to this object. Use CesiumUtility::IntrusivePointer instead of calling this method directly. | |
void | releaseReference () const |
Removes a counted reference from this object. When the last reference is removed, this method will delete this instance. Use CesiumUtility::IntrusivePointer instead of calling this method directly. | |
std::int32_t | getReferenceCount () const noexcept |
Returns the current reference count of this instance. | |
Public Member Functions inherited from CesiumUtility::IDepotOwningAsset< TAssetType > |
Public Attributes | |
int64_t | inactiveAssetSizeLimitBytes = 16 * 1024 * 1024 |
The maximum total byte usage of assets that have been loaded but are no longer needed. | |
A depot for CesiumUtility::SharedAsset
instances, which are potentially shared between multiple objects.
TAssetType | The type of asset stored in this depot. This should be derived from CesiumUtility::SharedAsset . |
Definition at line 11 of file SharedAsset.h.
using CesiumAsync::SharedAssetDepot< TAssetType, TAssetKey >::FactorySignature |
Signature for the callback function that will be called to fetch and create a new instance of TAssetType
if one with the given key doesn't already exist in the depot.
asyncSystem | The AsyncSystem used by this SharedAssetDepot. |
pAssetAccessor | The IAssetAccessor used by this SharedAssetDepot. Use this to fetch the asset. |
key | The TAssetKey for the asset that should be loaded by this factory. |
Definition at line 66 of file SharedAssetDepot.h.
CesiumAsync::SharedAssetDepot< TAssetType, TAssetKey >::SharedAssetDepot | ( | std::function< FactorySignature > | factory | ) |
Creates a new SharedAssetDepot
using the given factory callback to load new assets.
factory | The factory to use to fetch and create assets that don't already exist in the depot. See FactorySignature. |
Definition at line 272 of file SharedAssetDepot.h.
|
virtual |
Definition at line 283 of file SharedAssetDepot.h.
size_t CesiumAsync::SharedAssetDepot< TAssetType, TAssetKey >::getActiveAssetCount | ( | ) | const |
Gets the number of assets owned by this depot that are active, meaning that they are currently being used in one or more places.
Definition at line 411 of file SharedAssetDepot.h.
size_t CesiumAsync::SharedAssetDepot< TAssetType, TAssetKey >::getAssetCount | ( | ) | const |
Returns the total number of distinct assets contained in this depot, including both active and inactive assets.
Definition at line 405 of file SharedAssetDepot.h.
size_t CesiumAsync::SharedAssetDepot< TAssetType, TAssetKey >::getInactiveAssetCount | ( | ) | const |
Gets the number of assets owned by this depot that are inactive, meaning that they are not currently being used.
Definition at line 417 of file SharedAssetDepot.h.
int64_t CesiumAsync::SharedAssetDepot< TAssetType, TAssetKey >::getInactiveAssetTotalSizeBytes | ( | ) | const |
Gets the total bytes used by inactive (unused) assets owned by this depot.
Definition at line 424 of file SharedAssetDepot.h.
SharedFuture< CesiumUtility::ResultPointer< TAssetType > > CesiumAsync::SharedAssetDepot< TAssetType, TAssetKey >::getOrCreate | ( | const AsyncSystem & | asyncSystem, |
const std::shared_ptr< IAssetAccessor > & | pAssetAccessor, | ||
const TAssetKey & | assetKey ) |
Gets an asset from the depot if it already exists, or creates it using the depot's factory if it does not.
asyncSystem | The async system. |
pAssetAccessor | The asset accessor to use to download assets, if necessary. |
assetKey | The key uniquely identifying the asset to get or create. |
Definition at line 310 of file SharedAssetDepot.h.
int64_t CesiumAsync::SharedAssetDepot< TAssetType, TAssetKey >::inactiveAssetSizeLimitBytes = 16 * 1024 * 1024 |
The maximum total byte usage of assets that have been loaded but are no longer needed.
When cached assets are no longer needed, they're marked as candidates for deletion. However, this deletion doesn't actually occur until the total byte usage of deletion candidates exceeds this threshold. At that point, assets are cleaned up in the order that they were marked for deletion until the total dips below this threshold again.
Default is 16MiB.
Definition at line 50 of file SharedAssetDepot.h.