mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 04:14:38 +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) {
|
SharedNodePointer LimitedNodeList::nodeWithUUID(const QUuid& nodeUUID) {
|
||||||
|
QReadLocker readLocker(&_nodeMutex);
|
||||||
|
|
||||||
NodeHash::const_iterator it = _nodeHash.find(nodeUUID);
|
NodeHash::const_iterator it = _nodeHash.find(nodeUUID);
|
||||||
return it == _nodeHash.cend() ? SharedNodePointer() : it->second;
|
return it == _nodeHash.cend() ? SharedNodePointer() : it->second;
|
||||||
}
|
}
|
||||||
|
@ -386,10 +388,14 @@ void LimitedNodeList::reset() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LimitedNodeList::killNodeWithUUID(const QUuid& nodeUUID) {
|
void LimitedNodeList::killNodeWithUUID(const QUuid& nodeUUID) {
|
||||||
|
_nodeMutex.lockForRead();
|
||||||
|
|
||||||
NodeHash::iterator it = _nodeHash.find(nodeUUID);
|
NodeHash::iterator it = _nodeHash.find(nodeUUID);
|
||||||
if (it != _nodeHash.end()) {
|
if (it != _nodeHash.end()) {
|
||||||
SharedNodePointer matchingNode = it->second;
|
SharedNodePointer matchingNode = it->second;
|
||||||
|
|
||||||
|
_nodeMutex.unlock();
|
||||||
|
|
||||||
QWriteLocker writeLocker(&_nodeMutex);
|
QWriteLocker writeLocker(&_nodeMutex);
|
||||||
_nodeHash.unsafe_erase(it);
|
_nodeHash.unsafe_erase(it);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue