diff --git a/src/mbgl/tile/tile_cache.cpp b/src/mbgl/tile/tile_cache.cpp index c0c534a2c75..9a05cefaaf4 100644 --- a/src/mbgl/tile/tile_cache.cpp +++ b/src/mbgl/tile/tile_cache.cpp @@ -13,10 +13,8 @@ TileCache::~TileCache() { clear(); pendingReleases.clear(); - std::unique_lock counterLock(deferredSignalLock); - while (deferredDeletionsPending != 0) { - deferredSignal.wait(counterLock); - } + std::unique_lock counterLock{deferredSignalLock}; + deferredSignal.wait(counterLock, [&]() { return deferredDeletionsPending == 0; }); } void TileCache::setSize(size_t size_) { @@ -94,6 +92,7 @@ void TileCache::deferPendingReleases() { deferredDeletionsPending--; deferredSignal.notify_all(); }}; + threadPool.schedule(std::move(func)); }