LLDB
mainline
llvm-project
lldb
source
Target
TargetAPIMutex.cpp
Go to the documentation of this file.
1
//===----------------------------------------------------------------------===//
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
#include "
lldb/Target/TargetAPIMutex.h
"
10
#include "
lldb/Target/Target.h
"
11
12
using namespace
lldb_private
;
13
14
void
TargetAPIMutex::Resolve
() {
15
if
(!
m_target_sp
)
16
return
;
17
18
std::recursive_mutex *real_mutex =
m_target_sp
->GetAPIMutexForCurrentPolicy();
19
m_mutex
= real_mutex
20
? std::shared_ptr<std::recursive_mutex>(
m_target_sp
, real_mutex)
21
:
nullptr
;
22
}
23
24
void
TargetAPIMutex::lock
() {
25
Resolve
();
26
if
(
m_mutex
)
27
m_mutex
->lock();
28
}
29
30
bool
TargetAPIMutex::try_lock
() {
31
Resolve
();
32
return
m_mutex
?
m_mutex
->try_lock() :
true
;
33
}
TargetAPIMutex.h
Target.h
lldb_private::TargetAPIMutex::m_mutex
std::shared_ptr< std::recursive_mutex > m_mutex
An aliasing shared_ptr into m_target_sp's own mutex, resolved fresh on every lock()/try_lock() call.
Definition
TargetAPIMutex.h:65
lldb_private::TargetAPIMutex::try_lock
bool try_lock()
Definition
TargetAPIMutex.cpp:30
lldb_private::TargetAPIMutex::Resolve
void Resolve()
Definition
TargetAPIMutex.cpp:14
lldb_private::TargetAPIMutex::lock
void lock()
Definition
TargetAPIMutex.cpp:24
lldb_private::TargetAPIMutex::m_target_sp
lldb::TargetSP m_target_sp
Definition
TargetAPIMutex.h:66
lldb_private
A class that represents a running process on the host machine.
Definition
SBAddressRange.h:14
Generated on
for LLDB by
1.14.0