Author: Augusto Noronha
Date: 2023-08-15T11:33:34-07:00
New Revision: 4a390a56aeeb521d0eca1fa4cef6837157ea64ab

URL: 
https://github.com/llvm/llvm-project/commit/4a390a56aeeb521d0eca1fa4cef6837157ea64ab
DIFF: 
https://github.com/llvm/llvm-project/commit/4a390a56aeeb521d0eca1fa4cef6837157ea64ab.diff

LOG: [lldb] Implement ModuleList::Swap

Added: 
    

Modified: 
    lldb/include/lldb/Core/ModuleList.h
    lldb/source/Core/ModuleList.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Core/ModuleList.h 
b/lldb/include/lldb/Core/ModuleList.h
index 28c1945c83c478..9826dd09e91d71 100644
--- a/lldb/include/lldb/Core/ModuleList.h
+++ b/lldb/include/lldb/Core/ModuleList.h
@@ -480,6 +480,9 @@ class ModuleList {
   bool AnyOf(
       std::function<bool(lldb_private::Module &module)> const &callback) const;
 
+  /// Atomically swaps the contents of this module list with \a other.
+  void Swap(ModuleList &other);
+
 protected:
   // Class typedefs.
   typedef std::vector<lldb::ModuleSP>

diff  --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp
index d0d0b2050e181c..6cb086f9f55d2c 100644
--- a/lldb/source/Core/ModuleList.cpp
+++ b/lldb/source/Core/ModuleList.cpp
@@ -1079,3 +1079,10 @@ bool ModuleList::AnyOf(
 
   return false;
 }
+
+
+void ModuleList::Swap(ModuleList &other) {
+  // scoped_lock locks both mutexes at once.
+  std::scoped_lock lock(m_modules_mutex, other.m_modules_mutex);
+  m_modules.swap(other.m_modules);
+}


        
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to