We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b968d86 commit 7c96a10Copy full SHA for 7c96a10
include/CacheManager.h
@@ -11,14 +11,15 @@ class CacheManager {
11
CacheManager(int capacity);
12
void setPolicy(int policy);
13
void accessCache(int key, int value);
14
- void switchPolicy();
+ // Modified to accept a stop flag
15
+ void switchPolicy(std::atomic<bool>& stop_flag);
16
17
private:
18
enum { LFU = 0, LRU = 1 };
19
20
LFUCache lfu_cache;
21
LRUCache lru_cache;
- std::atomic<int> current_policy; // Use atomic for thread safety
22
+ std::atomic<int> current_policy;
23
std::mutex policy_mutex;
24
std::mutex access_mutex;
25
};
0 commit comments