ScopedWrite#
Fully qualified name: carb::input::ScopedWrite
Defined in carb/input/IInput.h
-
class ScopedWrite#
A RAII class for holding a write lock over multiple operations.
Public Functions
-
inline ScopedWrite(IInput *iface, ActionMappingSetHandle set)#
Constructor.
Once constructed, a write lock is held until
*thisis destroyed. Locks are recursive. Write locks should be held across any IInput functions that take a non-const ActionMappingSet handle, but may also be held across read-only functions as well (functions that take aconstActionMappingSet handle).Warning
It is possible to take a
ScopedWritelock after a ScopedRead lock. However, in this situation all locks are temporarily removed while an exclusive lock is obtained. The state of the object is therefore allowed to change immediately prior to taking theScopedWrite. To minimize this occurrence, operations which may require a write lock should take a speculativeScopedWriteinstead of ScopedRead followed by a laterScopedWrite.- Parameters:
iface – The IInput interface to use.
set – The ActionMappingSet handle to hold the lock on.
-
inline ~ScopedWrite()#
Destructor; releases the lock.
Warning
It is undefined behavior to allow
*thisto be destroyed by a different thread than the one that created it.
-
inline ScopedWrite(ScopedWrite &&other)#
Move constructor; moves a lock from another
ScopedWriteobject.Warning
It is undefined behavior to cause the moved
ScopedWriteto be destroyed by a different thread than the one that created it.- Parameters:
other – The lock to move from. Will be left in a valid but inactive state.
-
inline ScopedWrite &operator=(ScopedWrite &&other)#
Move-assign operator; moves a lock from another
ScopedWriteobject.Warning
It is undefined behavior to cause the moved
ScopedWriteto be destroyed by a different thread than the one that created it.- Parameters:
other – The lock to move from. Effectively swapped with
*this.- Returns:
*this.
-
inline ScopedWrite(IInput *iface, ActionMappingSetHandle set)#