aboutsummaryrefslogtreecommitdiff
path: root/include/lldb/Core/ThreadSafeValue.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/lldb/Core/ThreadSafeValue.h')
-rw-r--r--include/lldb/Core/ThreadSafeValue.h83
1 files changed, 31 insertions, 52 deletions
diff --git a/include/lldb/Core/ThreadSafeValue.h b/include/lldb/Core/ThreadSafeValue.h
index cad36a0c1637..60eaf91c4f02 100644
--- a/include/lldb/Core/ThreadSafeValue.h
+++ b/include/lldb/Core/ThreadSafeValue.h
@@ -20,71 +20,50 @@
namespace lldb_private {
-template <class T>
-class ThreadSafeValue
-{
+template <class T> class ThreadSafeValue {
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- ThreadSafeValue() : m_value(), m_mutex() {}
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ ThreadSafeValue() : m_value(), m_mutex() {}
- ThreadSafeValue(const T &value) : m_value(value), m_mutex() {}
+ ThreadSafeValue(const T &value) : m_value(value), m_mutex() {}
- ~ThreadSafeValue()
- {
- }
+ ~ThreadSafeValue() {}
- T
- GetValue() const
+ T GetValue() const {
+ T value;
{
- T value;
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- value = m_value;
- }
- return value;
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ value = m_value;
}
+ return value;
+ }
- // Call this if you have already manually locked the mutex using the
- // GetMutex() accessor
- const T&
- GetValueNoLock () const
- {
- return m_value;
- }
+ // Call this if you have already manually locked the mutex using the
+ // GetMutex() accessor
+ const T &GetValueNoLock() const { return m_value; }
- void
- SetValue(const T &value)
- {
- std::lock_guard<std::recursive_mutex> guard(m_mutex);
- m_value = value;
- }
+ void SetValue(const T &value) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ m_value = value;
+ }
- // Call this if you have already manually locked the mutex using the
- // GetMutex() accessor
- void
- SetValueNoLock (const T& value)
- {
- m_value = value;
- }
+ // Call this if you have already manually locked the mutex using the
+ // GetMutex() accessor
+ void SetValueNoLock(const T &value) { m_value = value; }
- std::recursive_mutex &
- GetMutex()
- {
- return m_mutex;
- }
+ std::recursive_mutex &GetMutex() { return m_mutex; }
private:
- T m_value;
- mutable std::recursive_mutex m_mutex;
+ T m_value;
+ mutable std::recursive_mutex m_mutex;
- //------------------------------------------------------------------
- // For ThreadSafeValue only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (ThreadSafeValue);
+ //------------------------------------------------------------------
+ // For ThreadSafeValue only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN(ThreadSafeValue);
};
-
} // namespace lldb_private
-#endif // liblldb_ThreadSafeValue_h_
+#endif // liblldb_ThreadSafeValue_h_