LLDB mainline
common/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
9#ifndef _WIN32
11
12namespace lldb_private {
13
15 int err = ::pthread_rwlock_init(&m_rwlock, nullptr);
16 (void)err;
17}
18
20 int err = ::pthread_rwlock_destroy(&m_rwlock);
21 (void)err;
22}
23
25 ::pthread_rwlock_rdlock(&m_rwlock);
26 if (!m_running) {
27 // coverity[missing_unlock]
28 return true;
29 }
30 ::pthread_rwlock_unlock(&m_rwlock);
31 return false;
32}
33
35 return ::pthread_rwlock_unlock(&m_rwlock) == 0;
36}
37
39 ::pthread_rwlock_wrlock(&m_rwlock);
40 bool was_stopped = !m_running;
41 m_running = true;
42 ::pthread_rwlock_unlock(&m_rwlock);
43 return was_stopped;
44}
45
47 ::pthread_rwlock_wrlock(&m_rwlock);
48 bool was_running = m_running;
49 m_running = false;
50 ::pthread_rwlock_unlock(&m_rwlock);
51 return was_running;
52}
53
54} // namespace lldb_private
55
56#endif
bool SetStopped()
Set the process to stopped.
bool SetRunning()
Set the process to running.
A class that represents a running process on the host machine.