mirror of
https://github.com/lubosz/overte.git
synced 2025-04-23 21:53:45 +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();
|
||||
|
||||
if (_actionDataDirty) {
|
||||
EntityItem* unconstThis = const_cast<EntityItem*>(this);
|
||||
unconstThis->withWriteLock([&] {
|
||||
withWriteLock([&] {
|
||||
getActionDataInternal();
|
||||
result = _allActionsDataCache;
|
||||
});
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
class ReadWriteLockable {
|
||||
public:
|
||||
template <typename F>
|
||||
bool withWriteLock(F f, bool require = true) {
|
||||
bool withWriteLock(F f, bool require = true) const {
|
||||
if (!require) {
|
||||
bool result = _lock.tryLockForWrite();
|
||||
if (result) {
|
||||
|
@ -22,7 +22,7 @@ public:
|
|||
_lock.unlock();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
QWriteLocker locker(&_lock);
|
||||
f();
|
||||
|
@ -30,7 +30,7 @@ public:
|
|||
}
|
||||
|
||||
template <typename F>
|
||||
bool withTryWriteLock(F f) {
|
||||
bool withTryWriteLock(F f) const {
|
||||
return withWriteLock(f, false);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue