diff --git a/src/ConfigurationCache.h b/src/ConfigurationCache.h index f9717487..5869630f 100644 --- a/src/ConfigurationCache.h +++ b/src/ConfigurationCache.h @@ -11,12 +11,12 @@ 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_)) @@ -24,25 +24,25 @@ namespace OpenWifi { 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 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