mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 19:04:32 +02:00
Atomics for better thread safety.
This commit is contained in:
parent
bbd977777a
commit
4ea8e7de5d
4 changed files with 6 additions and 6 deletions
|
@ -1117,7 +1117,7 @@ void MetavoxelNode::writeSpannerSubdivision(MetavoxelStreamState& state) const {
|
|||
}
|
||||
|
||||
void MetavoxelNode::decrementReferenceCount(const AttributePointer& attribute) {
|
||||
if (--_referenceCount == 0) {
|
||||
if (!_referenceCount.deref()) {
|
||||
destroy(attribute);
|
||||
delete this;
|
||||
}
|
||||
|
|
|
@ -212,7 +212,7 @@ public:
|
|||
void writeSpannerSubdivision(MetavoxelStreamState& state) const;
|
||||
|
||||
/// Increments the node's reference count.
|
||||
void incrementReferenceCount() { _referenceCount++; }
|
||||
void incrementReferenceCount() { _referenceCount.ref(); }
|
||||
|
||||
/// Decrements the node's reference count. If the resulting reference count is zero, destroys the node
|
||||
/// and calls delete this.
|
||||
|
@ -238,7 +238,7 @@ private:
|
|||
|
||||
friend class MetavoxelVisitation;
|
||||
|
||||
int _referenceCount;
|
||||
QAtomicInt _referenceCount;
|
||||
void* _attributeValue;
|
||||
MetavoxelNode* _children[CHILD_COUNT];
|
||||
};
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
REGISTER_META_OBJECT(SharedObject)
|
||||
|
||||
SharedObject::SharedObject() :
|
||||
_id(++_lastID),
|
||||
_id(_nextID.fetchAndAddOrdered(1)),
|
||||
_originID(_id),
|
||||
_remoteID(0),
|
||||
_remoteOriginID(0) {
|
||||
|
@ -131,7 +131,7 @@ void SharedObject::dump(QDebug debug) const {
|
|||
}
|
||||
}
|
||||
|
||||
int SharedObject::_lastID = 0;
|
||||
QAtomicInt SharedObject::_nextID(1);
|
||||
WeakSharedObjectHash SharedObject::_weakHash;
|
||||
QReadWriteLock SharedObject::_weakHashLock;
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ private:
|
|||
int _remoteOriginID;
|
||||
QAtomicInt _referenceCount;
|
||||
|
||||
static int _lastID;
|
||||
static QAtomicInt _nextID;
|
||||
static WeakSharedObjectHash _weakHash;
|
||||
static QReadWriteLock _weakHashLock;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue