Skip to content

Commit

Permalink
Flesh out utility functions slightly.
Browse files Browse the repository at this point in the history
  • Loading branch information
kring committed Oct 29, 2024
1 parent 7df4dc4 commit feaf448
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 15 deletions.
19 changes: 18 additions & 1 deletion Cesium3DTilesSelection/test/TestTilesetContentManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1682,11 +1682,28 @@ TEST_CASE("Test the tileset content manager's post processing for gltf") {
CHECK(images.size() == 1);
}

CHECK(pManager->getSharedAssetSystem()->pImage->getDistinctCount() == 2);
CHECK(
pManager->getSharedAssetSystem()
->pImage->getInactiveAssetTotalSizeBytes() == 0);
CHECK(pManager->getSharedAssetSystem()->pImage->getAssetCount() == 2);
CHECK(pManager->getSharedAssetSystem()->pImage->getActiveAssetCount() == 2);
CHECK(
pManager->getSharedAssetSystem()->pImage->getInactiveAssetCount() == 0);

// unload the tile content
for (auto& child : containerTile.getChildren()) {
pManager->unloadTileContent(child);
}

// Both of the assets will become inactive, and one of them will be
// destroyed, in order to bring the total under the limit.
CHECK(
pManager->getSharedAssetSystem()
->pImage->getInactiveAssetTotalSizeBytes() <=
pManager->getSharedAssetSystem()->pImage->staleAssetSizeLimit);
CHECK(pManager->getSharedAssetSystem()->pImage->getAssetCount() == 1);
CHECK(pManager->getSharedAssetSystem()->pImage->getActiveAssetCount() == 0);
CHECK(
pManager->getSharedAssetSystem()->pImage->getInactiveAssetCount() == 1);
}
}
31 changes: 17 additions & 14 deletions CesiumAsync/include/CesiumAsync/SharedAssetDepot.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,34 +195,37 @@ class CESIUMASYNC_API SharedAssetDepot
}

/**
* @brief Returns the total number of distinct assets contained in this depot.
* @brief Returns the total number of distinct assets contained in this depot,
* including both active and inactive assets.
*/
size_t getDistinctCount() const {
size_t getAssetCount() const {
std::lock_guard lock(this->_mutex);
return this->_assets.size();
}

/**
* @brief Returns the number of active references to assets in this depot.
* @brief 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 getUsageCount() const {
size_t getActiveAssetCount() const {
std::lock_guard lock(this->_mutex);

size_t count = 0;
for (const auto& [key, pEntry] : _assets) {
if (pEntry->pAsset) {
count += pEntry->pAsset->_referenceCount;
}
}
return count;
return this->_assets.size() - this->_deletionCandidates.size();
}

size_t getDeletionCandidateCount() const {
/**
* @brief Gets the number of assets owned by this depot that are inactive,
* meaning that they are not currently being used.
*/
size_t getInactiveAssetCount() const {
std::lock_guard lock(this->_mutex);
return this->_deletionCandidates.size();
}

int64_t getDeletionCandidateTotalSizeBytes() const {
/**
* @brief Gets the total bytes used by inactive (unused) assets owned by this
* depot.
*/
int64_t getInactiveAssetTotalSizeBytes() const {
std::lock_guard lock(this->_mutex);
return this->_totalDeletionCandidateMemoryUsage;
}
Expand Down

0 comments on commit feaf448

Please sign in to comment.