LLDB mainline
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
10#include "lldb/Target/Target.h"
11
12using namespace lldb_private;
13
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
25 Resolve();
26 if (m_mutex)
27 m_mutex->lock();
28}
29
31 Resolve();
32 return m_mutex ? m_mutex->try_lock() : true;
33}
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.
A class that represents a running process on the host machine.