================
@@ -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:

I also want to say that I don't mind the need to call 
`ProgressManager::Initialize()` before using parts of this class. I am mostly 
looking out for shut down crashes of the the LLDB library where the main thread 
exits first while other threads are not all terminated, which does happen. All 
of the places we have the comment:
```
// NOTE: intentional leak to avoid issues with C++ destructor chain
```
Was from tracking down shut down crashers in LLDB.

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

Reply via email to