mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 15:59:49 +02:00
make withWriteLock and withTryWriteLock const
This commit is contained in:
parent
a1096510e8
commit
22d6b6df34
2 changed files with 4 additions and 5 deletions
|
@ -1792,8 +1792,7 @@ const QByteArray EntityItem::getActionData() const {
|
||||||
assertUnlocked();
|
assertUnlocked();
|
||||||
|
|
||||||
if (_actionDataDirty) {
|
if (_actionDataDirty) {
|
||||||
EntityItem* unconstThis = const_cast<EntityItem*>(this);
|
withWriteLock([&] {
|
||||||
unconstThis->withWriteLock([&] {
|
|
||||||
getActionDataInternal();
|
getActionDataInternal();
|
||||||
result = _allActionsDataCache;
|
result = _allActionsDataCache;
|
||||||
});
|
});
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
class ReadWriteLockable {
|
class ReadWriteLockable {
|
||||||
public:
|
public:
|
||||||
template <typename F>
|
template <typename F>
|
||||||
bool withWriteLock(F f, bool require = true) {
|
bool withWriteLock(F f, bool require = true) const {
|
||||||
if (!require) {
|
if (!require) {
|
||||||
bool result = _lock.tryLockForWrite();
|
bool result = _lock.tryLockForWrite();
|
||||||
if (result) {
|
if (result) {
|
||||||
|
@ -22,7 +22,7 @@ public:
|
||||||
_lock.unlock();
|
_lock.unlock();
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QWriteLocker locker(&_lock);
|
QWriteLocker locker(&_lock);
|
||||||
f();
|
f();
|
||||||
|
@ -30,7 +30,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename F>
|
template <typename F>
|
||||||
bool withTryWriteLock(F f) {
|
bool withTryWriteLock(F f) const {
|
||||||
return withWriteLock(f, false);
|
return withWriteLock(f, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue