aboutsummaryrefslogtreecommitdiff
path: root/include/lldb/Host/ProcessRunLock.h
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-01-02 19:26:05 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-01-02 19:26:05 +0000
commit14f1b3e8826ce43b978db93a62d1166055db5394 (patch)
tree0a00ad8d3498783fe0193f3b656bca17c4c8697d /include/lldb/Host/ProcessRunLock.h
parent4ee8c119c71a06dcad1e0fecc8c675e480e59337 (diff)
downloadsrc-14f1b3e8826ce43b978db93a62d1166055db5394.tar.gz
src-14f1b3e8826ce43b978db93a62d1166055db5394.zip
Vendor import of lldb trunk r290819:vendor/lldb/lldb-trunk-r290819
Notes
Notes: svn path=/vendor/lldb/dist/; revision=311128 svn path=/vendor/lldb/lldb-trunk-r290819/; revision=311129; tag=vendor/lldb/lldb-trunk-r290819
Diffstat (limited to 'include/lldb/Host/ProcessRunLock.h')
-rw-r--r--include/lldb/Host/ProcessRunLock.h107
1 files changed, 45 insertions, 62 deletions
diff --git a/include/lldb/Host/ProcessRunLock.h b/include/lldb/Host/ProcessRunLock.h
index 797939a7edee..7044fdbd9ef9 100644
--- a/include/lldb/Host/ProcessRunLock.h
+++ b/include/lldb/Host/ProcessRunLock.h
@@ -18,7 +18,6 @@
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-defines.h"
-#include "lldb/Host/Condition.h"
//----------------------------------------------------------------------
/// Enumerations for broadcasting.
@@ -31,77 +30,61 @@ namespace lldb_private {
/// threads are accessing its data, and prevent access to its data while
/// it is running.
//----------------------------------------------------------------------
-
-class ProcessRunLock
-{
+
+class ProcessRunLock {
public:
- ProcessRunLock();
- ~ProcessRunLock();
-
- bool ReadTryLock ();
- bool ReadUnlock ();
- bool SetRunning ();
- bool TrySetRunning ();
- bool SetStopped ();
-
- class ProcessRunLocker
- {
- public:
- ProcessRunLocker () :
- m_lock (nullptr)
- {
- }
+ ProcessRunLock();
+ ~ProcessRunLock();
- ~ProcessRunLocker()
- {
- Unlock();
- }
+ bool ReadTryLock();
+ bool ReadUnlock();
+ bool SetRunning();
+ bool TrySetRunning();
+ bool SetStopped();
- // Try to lock the read lock, but only do so if there are no writers.
- bool
- TryLock (ProcessRunLock *lock)
- {
- if (m_lock)
- {
- if (m_lock == lock)
- return true; // We already have this lock locked
- else
- Unlock();
- }
- if (lock)
- {
- if (lock->ReadTryLock())
- {
- m_lock = lock;
- return true;
- }
- }
- return false;
- }
+ class ProcessRunLocker {
+ public:
+ ProcessRunLocker() : m_lock(nullptr) {}
- protected:
- void
- Unlock ()
- {
- if (m_lock)
- {
- m_lock->ReadUnlock();
- m_lock = nullptr;
- }
+ ~ProcessRunLocker() { Unlock(); }
+
+ // Try to lock the read lock, but only do so if there are no writers.
+ bool TryLock(ProcessRunLock *lock) {
+ if (m_lock) {
+ if (m_lock == lock)
+ return true; // We already have this lock locked
+ else
+ Unlock();
+ }
+ if (lock) {
+ if (lock->ReadTryLock()) {
+ m_lock = lock;
+ return true;
}
-
- ProcessRunLock *m_lock;
+ }
+ return false;
+ }
+
+ protected:
+ void Unlock() {
+ if (m_lock) {
+ m_lock->ReadUnlock();
+ m_lock = nullptr;
+ }
+ }
+
+ ProcessRunLock *m_lock;
- private:
- DISALLOW_COPY_AND_ASSIGN(ProcessRunLocker);
- };
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ProcessRunLocker);
+ };
protected:
- lldb::rwlock_t m_rwlock;
- bool m_running;
+ lldb::rwlock_t m_rwlock;
+ bool m_running;
private:
- DISALLOW_COPY_AND_ASSIGN(ProcessRunLock);
+ DISALLOW_COPY_AND_ASSIGN(ProcessRunLock);
};
} // namespace lldb_private