mirror of
https://github.com/intel/llvm.git
synced 2026-01-19 17:45:07 +08:00
Fix the copy constructor and assignement operator for ModuleList to be thread safe.
llvm-svn: 159285
This commit is contained in:
@@ -37,8 +37,12 @@ ModuleList::ModuleList() :
|
||||
// Copy constructor
|
||||
//----------------------------------------------------------------------
|
||||
ModuleList::ModuleList(const ModuleList& rhs) :
|
||||
m_modules(rhs.m_modules)
|
||||
m_modules(),
|
||||
m_modules_mutex (Mutex::eMutexTypeRecursive)
|
||||
{
|
||||
Mutex::Locker lhs_locker(m_modules_mutex);
|
||||
Mutex::Locker rhs_locker(rhs.m_modules_mutex);
|
||||
m_modules = rhs.m_modules;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@@ -49,7 +53,8 @@ ModuleList::operator= (const ModuleList& rhs)
|
||||
{
|
||||
if (this != &rhs)
|
||||
{
|
||||
Mutex::Locker locker(m_modules_mutex);
|
||||
Mutex::Locker lhs_locker(m_modules_mutex);
|
||||
Mutex::Locker rhs_locker(rhs.m_modules_mutex);
|
||||
m_modules = rhs.m_modules;
|
||||
}
|
||||
return *this;
|
||||
|
||||
Reference in New Issue
Block a user