================ @@ -66,3 +66,47 @@ void Progress::ReportProgress() { m_debugger_id); } } + +void ProgressManager::Initialize() { + lldbassert(!InstanceImpl() && "A progress report manager already exists."); + InstanceImpl().emplace(); +} + +void ProgressManager::Terminate() { + lldbassert(InstanceImpl() && + "A progress report manager has already been terminated."); + InstanceImpl().reset(); +} + +std::optional<ProgressManager> &ProgressManager::InstanceImpl() { + static std::optional<ProgressManager> g_progress_manager; + return g_progress_manager; +} + +ProgressManager::ProgressManager() : m_progress_map() {} + +ProgressManager::~ProgressManager() {} + +ProgressManager &ProgressManager::Instance() { return *InstanceImpl(); } + +void ProgressManager::Increment(std::string title) { + std::lock_guard<std::mutex> lock(m_progress_map_mutex); + auto pair = m_progress_map.insert(std::pair(title, 1)); + + // If pair.first is not empty after insertion it means that that + // category was entered for the first time and should not be incremented + if (!pair.first->first().empty()) ---------------- clayborg wrote:
This returns a `std::pair<iterator, bool>` where the bool designates if the instertion took place. So this should be: ``` if (!pair.second) ``` https://github.com/llvm/llvm-project/pull/81319 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits