mirror of https://github.com/Icinga/icinga2.git
Locked<T>: optimistically use SpinMutex to consume less RAM
std::mutex is 5 pointers large on x64, whereas std::atomic_flag at most one.
This commit is contained in:
parent
efc8266aa7
commit
37b4d107d9
|
@ -80,20 +80,20 @@ class Locked
|
|||
public:
|
||||
inline T load() const
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(m_Mutex);
|
||||
std::unique_lock lock (m_Mutex);
|
||||
|
||||
return m_Value;
|
||||
}
|
||||
|
||||
inline void store(T desired)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(m_Mutex);
|
||||
std::unique_lock lock (m_Mutex);
|
||||
|
||||
m_Value = std::move(desired);
|
||||
}
|
||||
|
||||
private:
|
||||
mutable std::mutex m_Mutex;
|
||||
mutable SpinMutex m_Mutex;
|
||||
T m_Value;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue