Skip to content

Commit ba38bef

Browse files
committed
[lldb] Implement ModuleList::Swap
1 parent 26456d7 commit ba38bef

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lldb/include/lldb/Core/ModuleList.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,9 @@ class ModuleList {
500500
bool AnyOf(
501501
std::function<bool(lldb_private::Module &module)> const &callback) const;
502502

503+
/// Atomically swaps the contents of this module list with \a other.
504+
void Swap(ModuleList &other);
505+
503506
protected:
504507
// Class typedefs.
505508
typedef std::vector<lldb::ModuleSP>

lldb/source/Core/ModuleList.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,3 +1295,10 @@ bool ModuleList::AnyOf(
12951295

12961296
return false;
12971297
}
1298+
1299+
1300+
void ModuleList::Swap(ModuleList &other) {
1301+
// scoped_lock locks both mutexes at once.
1302+
std::scoped_lock lock(m_modules_mutex, other.m_modules_mutex);
1303+
m_modules.swap(other.m_modules);
1304+
}

0 commit comments

Comments
 (0)