LLDB
mainline
llvm-project
lldb
source
Host
common
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
9
#include "
lldb/Host/MainLoopBase.h
"
10
11
using namespace
lldb
;
12
using namespace
lldb_private
;
13
14
void
MainLoopBase::AddPendingCallback
(
const
Callback
&callback) {
15
{
16
std::lock_guard<std::mutex> lock{
m_callback_mutex
};
17
m_pending_callbacks
.push_back(callback);
18
}
19
TriggerPendingCallbacks
();
20
}
21
22
void
MainLoopBase::ProcessPendingCallbacks
() {
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
}
MainLoopBase.h
lldb_private::MainLoopBase::TriggerPendingCallbacks
virtual void TriggerPendingCallbacks()=0
lldb_private::MainLoopBase::AddPendingCallback
void AddPendingCallback(const Callback &callback)
Definition:
MainLoopBase.cpp:14
lldb_private::MainLoopBase::Callback
std::function< void(MainLoopBase &)> Callback
Definition:
MainLoopBase.h:46
lldb_private::MainLoopBase::m_callback_mutex
std::mutex m_callback_mutex
Definition:
MainLoopBase.h:78
lldb_private::MainLoopBase::m_pending_callbacks
std::vector< Callback > m_pending_callbacks
Definition:
MainLoopBase.h:79
lldb_private::MainLoopBase::ProcessPendingCallbacks
void ProcessPendingCallbacks()
Definition:
MainLoopBase.cpp:22
lldb_private
A class that represents a running process on the host machine.
Definition:
SBAddressRange.h:14
lldb
Definition:
SBAddress.h:15
Generated on Sun Oct 6 2024 19:32:35 for LLDB by
1.9.6