From d5c44466c4af7d281d630557df9b41d7aaf13b76 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Tue, 10 Nov 2015 18:24:41 -0800 Subject: [PATCH] Take Callables with rvalue ref --- .../shared/src/shared/ReadWriteLockable.h | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/libraries/shared/src/shared/ReadWriteLockable.h b/libraries/shared/src/shared/ReadWriteLockable.h index 04aa20a067..9279628e10 100644 --- a/libraries/shared/src/shared/ReadWriteLockable.h +++ b/libraries/shared/src/shared/ReadWriteLockable.h @@ -21,37 +21,37 @@ class ReadWriteLockable { public: // Write locks template - bool withWriteLock(F f) const; + bool withWriteLock(F&& f) const; template bool withWriteLock(F&& f, bool require) const; template - bool withTryWriteLock(F f) const; + bool withTryWriteLock(F&& f) const; template - bool withTryWriteLock(F f, int timeout) const; + bool withTryWriteLock(F&& f, int timeout) const; // Read locks template - bool withReadLock(F f) const; + bool withReadLock(F&& f) const; template bool withReadLock(F&& f, bool require) const; template - bool withTryReadLock(F f) const; + bool withTryReadLock(F&& f) const; template - bool withTryReadLock(F f, int timeout) const; + bool withTryReadLock(F&& f, int timeout) const; private: - mutable QReadWriteLock _lock{ QReadWriteLock::Recursive }; + mutable QReadWriteLock _lock { QReadWriteLock::Recursive }; }; // ReadWriteLockable template -inline bool ReadWriteLockable::withWriteLock(F f) const { +inline bool ReadWriteLockable::withWriteLock(F&& f) const { QWriteLocker locker(&_lock); f(); return true; @@ -67,7 +67,7 @@ inline bool ReadWriteLockable::withWriteLock(F&& f, bool require) const { } template -inline bool ReadWriteLockable::withTryWriteLock(F f) const { +inline bool ReadWriteLockable::withTryWriteLock(F&& f) const { QTryWriteLocker locker(&_lock); if (locker.isLocked()) { f(); @@ -77,7 +77,7 @@ inline bool ReadWriteLockable::withTryWriteLock(F f) const { } template -inline bool ReadWriteLockable::withTryWriteLock(F f, int timeout) const { +inline bool ReadWriteLockable::withTryWriteLock(F&& f, int timeout) const { QTryWriteLocker locker(&_lock, timeout); if (locker.isLocked()) { f(); @@ -87,7 +87,7 @@ inline bool ReadWriteLockable::withTryWriteLock(F f, int timeout) const { } template -inline bool ReadWriteLockable::withReadLock(F f) const { +inline bool ReadWriteLockable::withReadLock(F&& f) const { QReadLocker locker(&_lock); f(); return true; @@ -103,7 +103,7 @@ inline bool ReadWriteLockable::withReadLock(F&& f, bool require) const { } template -inline bool ReadWriteLockable::withTryReadLock(F f) const { +inline bool ReadWriteLockable::withTryReadLock(F&& f) const { QTryReadLocker locker(&_lock); if (locker.isLocked()) { f(); @@ -113,7 +113,7 @@ inline bool ReadWriteLockable::withTryReadLock(F f) const { } template -inline bool ReadWriteLockable::withTryReadLock(F f, int timeout) const { +inline bool ReadWriteLockable::withTryReadLock(F&& f, int timeout) const { QTryReadLocker locker(&_lock, timeout); if (locker.isLocked()) { f();