Skip to content

Commit 7c96a10

Browse files
authored
Update CacheManager.h
1 parent b968d86 commit 7c96a10

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

include/CacheManager.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ class CacheManager {
1111
CacheManager(int capacity);
1212
void setPolicy(int policy);
1313
void accessCache(int key, int value);
14-
void switchPolicy();
14+
// Modified to accept a stop flag
15+
void switchPolicy(std::atomic<bool>& stop_flag);
1516

1617
private:
1718
enum { LFU = 0, LRU = 1 };
1819

1920
LFUCache lfu_cache;
2021
LRUCache lru_cache;
21-
std::atomic<int> current_policy; // Use atomic for thread safety
22+
std::atomic<int> current_policy;
2223
std::mutex policy_mutex;
2324
std::mutex access_mutex;
2425
};

0 commit comments

Comments
 (0)