1 //===-- ProcessRunLock.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_ProcessRunLock_h_
11 #define liblldb_ProcessRunLock_h_
18 // Other libraries and framework includes
20 #include "lldb/lldb-defines.h"
21 #include "lldb/Host/Mutex.h"
22 #include "lldb/Host/Condition.h"
24 //----------------------------------------------------------------------
25 /// Enumerations for broadcasting.
26 //----------------------------------------------------------------------
27 namespace lldb_private {
29 //----------------------------------------------------------------------
30 /// @class ProcessRunLock ProcessRunLock.h "lldb/Host/ProcessRunLock.h"
31 /// @brief A class used to prevent the process from starting while other
32 /// threads are accessing its data, and prevent access to its data while
34 //----------------------------------------------------------------------
45 bool TrySetRunning ();
48 class ProcessRunLocker
61 // Try to lock the read lock, but only do so if there are no writers.
63 TryLock (ProcessRunLock *lock)
68 return true; // We already have this lock locked
74 if (lock->ReadTryLock())
94 ProcessRunLock *m_lock;
97 DISALLOW_COPY_AND_ASSIGN(ProcessRunLocker);
101 lldb::rwlock_t m_rwlock;
105 DISALLOW_COPY_AND_ASSIGN(ProcessRunLock);
108 } // namespace lldb_private
110 #endif // liblldb_ProcessRunLock_h_