Avoid dead-lock if other = this
This commit is contained in:
parent
688b1f8bef
commit
22479ff5d8
@ -30,17 +30,23 @@ struct ConcurrentIDMap
|
||||
ConcurrentIDMap() = default;
|
||||
ConcurrentIDMap(ConcurrentIDMap &&other)
|
||||
{
|
||||
ScopedWriterLock other_lock{other.mutex};
|
||||
ScopedWriterLock lock{mutex};
|
||||
if (this != &other)
|
||||
{
|
||||
ScopedWriterLock other_lock{other.mutex};
|
||||
ScopedWriterLock lock{mutex};
|
||||
|
||||
data = std::move(other.data);
|
||||
data = std::move(other.data);
|
||||
}
|
||||
}
|
||||
ConcurrentIDMap &operator=(ConcurrentIDMap &&other)
|
||||
{
|
||||
ScopedWriterLock other_lock{other.mutex};
|
||||
ScopedWriterLock lock{mutex};
|
||||
if (this != &other)
|
||||
{
|
||||
ScopedWriterLock other_lock{other.mutex};
|
||||
ScopedWriterLock lock{mutex};
|
||||
|
||||
data = std::move(other.data);
|
||||
data = std::move(other.data);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user