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