Path: blob/main/contrib/llvm-project/lldb/source/Host/common/MainLoopBase.cpp
39606 views
//===-- MainLoopBase.cpp --------------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "lldb/Host/MainLoopBase.h"910using namespace lldb;11using namespace lldb_private;1213void MainLoopBase::AddPendingCallback(const Callback &callback) {14{15std::lock_guard<std::mutex> lock{m_callback_mutex};16m_pending_callbacks.push_back(callback);17}18TriggerPendingCallbacks();19}2021void MainLoopBase::ProcessPendingCallbacks() {22// Move the callbacks to a local vector to avoid keeping m_pending_callbacks23// locked throughout the calls.24std::vector<Callback> pending_callbacks;25{26std::lock_guard<std::mutex> lock{m_callback_mutex};27pending_callbacks = std::move(m_pending_callbacks);28}2930for (const Callback &callback : pending_callbacks)31callback(*this);32}333435