[Lldb-commits] [lldb] [lldb][progress] Add progress manager class (PR #81319)

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Fri Feb 9 15:06:14 PST 2024


================
@@ -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(); }
----------------
clayborg wrote:

Another reason for using the `std::once` is if no one tries to listen to the eBroadcastBitProgressCategory, then nothing will need to be created. If not we are always making an instance. Granted this object isn't very expensive to create, but it is extra work that might not be needed.

https://github.com/llvm/llvm-project/pull/81319


More information about the lldb-commits mailing list