From dc0240418499fa7c9837d0b2d2cd7a0f9f3a5c49 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Mon, 27 Jun 2022 00:58:56 -0700 Subject: [PATCH] [Metadata Cache] Actually run cleanup thread Previously, the cleanup thread was not being run. Also, only reset the metadata deduplication store when the cache is first emptied. Signed-off-by: Christopher Snowhill --- Audio/PluginController.mm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Audio/PluginController.mm b/Audio/PluginController.mm index bc4207e28..ab739d077 100644 --- a/Audio/PluginController.mm +++ b/Audio/PluginController.mm @@ -109,11 +109,16 @@ static NSDictionary *cache_access_metadata(NSURL *url) { static void cache_run() { std::chrono::milliseconds dura(250); + Cache_Running = true; + while(Cache_Running) { std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now(); @autoreleasepool { std::lock_guard lock(Cache_Lock); + + size_t cacheListOriginalSize = Cache_List.size(); + for(auto it = Cache_List.begin(); it != Cache_List.end();) { auto elapsed = std::chrono::duration_cast(now - it->second.time_accessed); if(elapsed.count() >= 10) { @@ -123,8 +128,9 @@ static void cache_run() { ++it; } - if(Cache_List.size() == 0) + if(cacheListOriginalSize && Cache_List.size() == 0) { [Cache_Data_Store reset]; + } } std::this_thread::sleep_for(dura);