[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 <kode54@gmail.com>lastfm
parent
bb11567948
commit
dc02404184
|
@ -109,11 +109,16 @@ static NSDictionary *cache_access_metadata(NSURL *url) {
|
||||||
static void cache_run() {
|
static void cache_run() {
|
||||||
std::chrono::milliseconds dura(250);
|
std::chrono::milliseconds dura(250);
|
||||||
|
|
||||||
|
Cache_Running = true;
|
||||||
|
|
||||||
while(Cache_Running) {
|
while(Cache_Running) {
|
||||||
std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
|
std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
|
||||||
|
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
std::lock_guard<std::mutex> lock(Cache_Lock);
|
std::lock_guard<std::mutex> lock(Cache_Lock);
|
||||||
|
|
||||||
|
size_t cacheListOriginalSize = Cache_List.size();
|
||||||
|
|
||||||
for(auto it = Cache_List.begin(); it != Cache_List.end();) {
|
for(auto it = Cache_List.begin(); it != Cache_List.end();) {
|
||||||
auto elapsed = std::chrono::duration_cast<std::chrono::seconds>(now - it->second.time_accessed);
|
auto elapsed = std::chrono::duration_cast<std::chrono::seconds>(now - it->second.time_accessed);
|
||||||
if(elapsed.count() >= 10) {
|
if(elapsed.count() >= 10) {
|
||||||
|
@ -123,9 +128,10 @@ static void cache_run() {
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Cache_List.size() == 0)
|
if(cacheListOriginalSize && Cache_List.size() == 0) {
|
||||||
[Cache_Data_Store reset];
|
[Cache_Data_Store reset];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::this_thread::sleep_for(dura);
|
std::this_thread::sleep_for(dura);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue