From 37b4d107d9a29ddbe723cc239114d1b8123ce3e6 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Mon, 26 Aug 2024 17:18:58 +0200 Subject: [PATCH] Locked: optimistically use SpinMutex to consume less RAM std::mutex is 5 pointers large on x64, whereas std::atomic_flag at most one. --- lib/base/atomic.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/base/atomic.hpp b/lib/base/atomic.hpp index 29d158cf0..797d7d7f3 100644 --- a/lib/base/atomic.hpp +++ b/lib/base/atomic.hpp @@ -80,20 +80,20 @@ class Locked public: inline T load() const { - std::unique_lock lock(m_Mutex); + std::unique_lock lock (m_Mutex); return m_Value; } inline void store(T desired) { - std::unique_lock 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; };