LLDB mainline
MainLoopBase.cpp
Go to the documentation of this file.
1//===-- MainLoopBase.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
10
11using namespace lldb;
12using namespace lldb_private;
13
15 {
16 std::lock_guard<std::mutex> lock{m_callback_mutex};
17 m_pending_callbacks.push_back(callback);
18 }
20}
21
23 // Move the callbacks to a local vector to avoid keeping m_pending_callbacks
24 // locked throughout the calls.
25 std::vector<Callback> pending_callbacks;
26 {
27 std::lock_guard<std::mutex> lock{m_callback_mutex};
28 pending_callbacks = std::move(m_pending_callbacks);
29 }
30
31 for (const Callback &callback : pending_callbacks)
32 callback(*this);
33}
virtual void TriggerPendingCallbacks()=0
void AddPendingCallback(const Callback &callback)
std::function< void(MainLoopBase &)> Callback
Definition: MainLoopBase.h:46
std::vector< Callback > m_pending_callbacks
Definition: MainLoopBase.h:79
A class that represents a running process on the host machine.
Definition: SBAddress.h:15