File indexing completed on 2026-05-10 08:42:49
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLDB_HOST_PROCESSRUNLOCK_H
0010 #define LLDB_HOST_PROCESSRUNLOCK_H
0011
0012 #include <cstdint>
0013 #include <ctime>
0014
0015 #include "lldb/lldb-defines.h"
0016
0017
0018 namespace lldb_private {
0019
0020
0021
0022
0023
0024
0025 class ProcessRunLock {
0026 public:
0027 ProcessRunLock();
0028 ~ProcessRunLock();
0029
0030 bool ReadTryLock();
0031 bool ReadUnlock();
0032 bool SetRunning();
0033 bool TrySetRunning();
0034 bool SetStopped();
0035
0036 class ProcessRunLocker {
0037 public:
0038 ProcessRunLocker() = default;
0039
0040 ~ProcessRunLocker() { Unlock(); }
0041
0042
0043 bool TryLock(ProcessRunLock *lock) {
0044 if (m_lock) {
0045 if (m_lock == lock)
0046 return true;
0047 else
0048 Unlock();
0049 }
0050 if (lock) {
0051 if (lock->ReadTryLock()) {
0052 m_lock = lock;
0053 return true;
0054 }
0055 }
0056 return false;
0057 }
0058
0059 protected:
0060 void Unlock() {
0061 if (m_lock) {
0062 m_lock->ReadUnlock();
0063 m_lock = nullptr;
0064 }
0065 }
0066
0067 ProcessRunLock *m_lock = nullptr;
0068
0069 private:
0070 ProcessRunLocker(const ProcessRunLocker &) = delete;
0071 const ProcessRunLocker &operator=(const ProcessRunLocker &) = delete;
0072 };
0073
0074 protected:
0075 lldb::rwlock_t m_rwlock;
0076 bool m_running = false;
0077
0078 private:
0079 ProcessRunLock(const ProcessRunLock &) = delete;
0080 const ProcessRunLock &operator=(const ProcessRunLock &) = delete;
0081 };
0082
0083 }
0084
0085 #endif