mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 14:03:55 +02:00
add read locks for find on tbb hash
This commit is contained in:
parent
df3eca5aca
commit
07f95c597c
1 changed files with 6 additions and 0 deletions
|
@ -352,6 +352,8 @@ int LimitedNodeList::findNodeAndUpdateWithDataFromPacket(const QByteArray& packe
|
|||
}
|
||||
|
||||
SharedNodePointer LimitedNodeList::nodeWithUUID(const QUuid& nodeUUID) {
|
||||
QReadLocker readLocker(&_nodeMutex);
|
||||
|
||||
NodeHash::const_iterator it = _nodeHash.find(nodeUUID);
|
||||
return it == _nodeHash.cend() ? SharedNodePointer() : it->second;
|
||||
}
|
||||
|
@ -386,10 +388,14 @@ void LimitedNodeList::reset() {
|
|||
}
|
||||
|
||||
void LimitedNodeList::killNodeWithUUID(const QUuid& nodeUUID) {
|
||||
_nodeMutex.lockForRead();
|
||||
|
||||
NodeHash::iterator it = _nodeHash.find(nodeUUID);
|
||||
if (it != _nodeHash.end()) {
|
||||
SharedNodePointer matchingNode = it->second;
|
||||
|
||||
_nodeMutex.unlock();
|
||||
|
||||
QWriteLocker writeLocker(&_nodeMutex);
|
||||
_nodeHash.unsafe_erase(it);
|
||||
|
||||
|
|
Loading…
Reference in a new issue