LLDB mainline
windows/ProcessRunLock.cpp
Go to the documentation of this file.
1//===-- ProcessRunLock.cpp ------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
11
12static PSRWLOCK GetLock(lldb::rwlock_t lock) {
13 return static_cast<PSRWLOCK>(lock);
14}
15
16static bool ReadLock(lldb::rwlock_t rwlock) {
17 ::AcquireSRWLockShared(GetLock(rwlock));
18 return true;
19}
20
21static bool ReadUnlock(lldb::rwlock_t rwlock) {
22 ::ReleaseSRWLockShared(GetLock(rwlock));
23 return true;
24}
25
26static bool WriteLock(lldb::rwlock_t rwlock) {
27 ::AcquireSRWLockExclusive(GetLock(rwlock));
28 return true;
29}
30
31static bool WriteTryLock(lldb::rwlock_t rwlock) {
32 return !!::TryAcquireSRWLockExclusive(GetLock(rwlock));
33}
34
35static bool WriteUnlock(lldb::rwlock_t rwlock) {
36 ::ReleaseSRWLockExclusive(GetLock(rwlock));
37 return true;
38}
39
40using namespace lldb_private;
41
42ProcessRunLock::ProcessRunLock() : m_running(false) {
43 m_rwlock = new SRWLOCK;
44 InitializeSRWLock(GetLock(m_rwlock));
45}
46
47ProcessRunLock::~ProcessRunLock() { delete static_cast<SRWLOCK *>(m_rwlock); }
48
51 if (m_running == false)
52 return true;
54 return false;
55}
56
57bool ProcessRunLock::ReadUnlock() { return ::ReadUnlock(m_rwlock); }
58
61 m_running = true;
63 return true;
64}
65
68 bool was_running = m_running;
69 m_running = true;
71 return !was_running;
72 }
73 return false;
74}
75
78 m_running = false;
80 return true;
81}
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
pthread_rwlock_t rwlock_t
Definition: lldb-types.h:56
static bool WriteTryLock(lldb::rwlock_t rwlock)
static PSRWLOCK GetLock(lldb::rwlock_t lock)
static bool ReadLock(lldb::rwlock_t rwlock)
static bool WriteLock(lldb::rwlock_t rwlock)
static bool WriteUnlock(lldb::rwlock_t rwlock)
static bool ReadUnlock(lldb::rwlock_t rwlock)