1 //===-- ThreadSafeValue.h ---------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_ThreadSafeValue_h_
11 #define liblldb_ThreadSafeValue_h_
15 // Other libraries and framework includes
17 #include "lldb/Host/Mutex.h"
19 namespace lldb_private {
25 //------------------------------------------------------------------
26 // Constructors and Destructors
27 //------------------------------------------------------------------
30 m_mutex (Mutex::eMutexTypeRecursive)
34 ThreadSafeValue(const T& value) :
36 m_mutex (Mutex::eMutexTypeRecursive)
49 Mutex::Locker locker(m_mutex);
55 // Call this if you have already manually locked the mutex using the
56 // GetMutex() accessor
58 GetValueNoLock () const
64 SetValue (const T& value)
66 Mutex::Locker locker(m_mutex);
70 // Call this if you have already manually locked the mutex using the
71 // GetMutex() accessor
73 SetValueNoLock (const T& value)
86 mutable Mutex m_mutex;
88 //------------------------------------------------------------------
89 // For ThreadSafeValue only
90 //------------------------------------------------------------------
91 DISALLOW_COPY_AND_ASSIGN (ThreadSafeValue);
95 } // namespace lldb_private
96 #endif // liblldb_ThreadSafeValue_h_