Skip to content

Commit

Permalink
https://telecominfraproject.atlassian.net/browse/WIFI-13268
Browse files Browse the repository at this point in the history
Signed-off-by: stephb9959 <[email protected]>
  • Loading branch information
stephb9959 committed Jan 4, 2024
1 parent a59d49e commit c802e35
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/ConfigurationCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,38 @@
namespace OpenWifi {
class ConfigurationCache {
public:
static ConfigurationCache &instance() {
static ConfigurationCache instance;
static auto instance() {
static auto instance = new ConfigurationCache;
return instance;
}

inline uint64_t CurrentConfig(uint64_t SerialNumber) {
inline uint64_t CurrentConfig(std::uint64_t SerialNumber) {
std::lock_guard G(Mutex_);
const auto Hint = Cache_.find(SerialNumber);
if (Hint == end(Cache_))
return 0;
return Hint->second;
}

inline void Add(uint64_t SerialNumber, uint64_t Id) {
inline void Add(std::uint64_t SerialNumber, uint64_t Id) {
std::lock_guard G(Mutex_);
Cache_[SerialNumber] = Id;
}

private:
std::recursive_mutex Mutex_;
std::mutex Mutex_;
std::map<uint64_t, uint64_t> Cache_;
};

inline uint64_t GetCurrentConfigurationID(uint64_t SerialNumber) {
return ConfigurationCache::instance().CurrentConfig(SerialNumber);
return ConfigurationCache::instance()->CurrentConfig(SerialNumber);
}

inline void SetCurrentConfigurationID(const std::string &SerialNumber, uint64_t ID) {
return ConfigurationCache::instance().Add(Utils::SerialNumberToInt(SerialNumber), ID);
return ConfigurationCache::instance()->Add(Utils::SerialNumberToInt(SerialNumber), ID);
}

inline void SetCurrentConfigurationID(uint64_t SerialNumber, uint64_t ID) {
return ConfigurationCache::instance().Add(SerialNumber, ID);
return ConfigurationCache::instance()->Add(SerialNumber, ID);
}
} // namespace OpenWifi

0 comments on commit c802e35

Please sign in to comment.