Skip to content

Commit

Permalink
release pending items before waiting
Browse files Browse the repository at this point in the history
  • Loading branch information
TimSylvester committed Nov 19, 2024
1 parent 877d12b commit 43f1272
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
12 changes: 12 additions & 0 deletions src/mbgl/tile/tile_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@

namespace mbgl {

TileCache::~TileCache() {
MLN_TRACE_FUNC();

clear();
pendingReleases.clear();

std::unique_lock<std::mutex> counterLock(deferredSignalLock);
while (deferredDeletionsPending != 0) {
deferredSignal.wait(counterLock);
}
}

void TileCache::setSize(size_t size_) {
MLN_TRACE_FUNC();

Expand Down
10 changes: 1 addition & 9 deletions src/mbgl/tile/tile_cache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,7 @@ class TileCache {
TileCache(const TaggedScheduler& threadPool_, size_t size_ = 0)
: threadPool(threadPool_),
size(size_) {}

~TileCache() {
clear();

std::unique_lock<std::mutex> counterLock(deferredSignalLock);
while (deferredDeletionsPending != 0) {
deferredSignal.wait(counterLock);
}
}
~TileCache();

/// Change the maximum size of the cache.
void setSize(size_t);
Expand Down

0 comments on commit 43f1272

Please sign in to comment.