Path: blob/main/contrib/llvm-project/lldb/source/API/SBProgress.cpp
213764 views
//===-- SBProgress.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/API/SBProgress.h"9#include "lldb/Core/Progress.h"10#include "lldb/Utility/Instrumentation.h"1112using namespace lldb;1314SBProgress::SBProgress(const char *title, const char *details,15SBDebugger &debugger) {16LLDB_INSTRUMENT_VA(this, title, details, debugger);1718m_opaque_up = std::make_unique<lldb_private::Progress>(19title, details, /*total=*/std::nullopt, debugger.get(),20/*minimum_report_time=*/std::nullopt,21lldb_private::Progress::Origin::eExternal);22}2324SBProgress::SBProgress(const char *title, const char *details,25uint64_t total_units, SBDebugger &debugger) {26LLDB_INSTRUMENT_VA(this, title, details, total_units, debugger);2728m_opaque_up = std::make_unique<lldb_private::Progress>(29title, details, total_units, debugger.get(),30/*minimum_report_time=*/std::nullopt,31lldb_private::Progress::Origin::eExternal);32}3334SBProgress::SBProgress(SBProgress &&rhs)35: m_opaque_up(std::move(rhs.m_opaque_up)) {}3637SBProgress::~SBProgress() = default;3839void SBProgress::Increment(uint64_t amount, const char *description) {40LLDB_INSTRUMENT_VA(amount, description);4142if (!m_opaque_up)43return;4445std::optional<std::string> description_opt;46if (description && description[0])47description_opt = description;48m_opaque_up->Increment(amount, std::move(description_opt));49}5051void SBProgress::Finalize() {52// The lldb_private::Progress object is designed to be RAII and send the end53// progress event when it gets destroyed. So force our contained object to be54// destroyed and send the progress end event. Clearing this object also allows55// all other methods to quickly return without doing any work if they are56// called after this method.57m_opaque_up.reset();58}5960lldb_private::Progress &SBProgress::ref() const { return *m_opaque_up; }616263