Base class for synchronization classes.
More...
#include <rw/sync/RWSynchObject.h>
RWSynchObject is the base class for synchronization classes, RWMutexLock, RWFIFOMutexLock, RWTRecursiveLock, RWSemaphore, RWCondition, RWReadersWriterLock, and RWCriticalSection. The class contains methods that support automatic cancellation detection for runnables containing a thread that is accessing the acquire() or wait() members of these derived classes.
- See also
- RWMutexLock, RWNullMutexLock, RWFIFOMutexLock, RWTRecursiveLock, RWReadersWriterLock, RWSemaphore, RWCondition, RWCriticalSection
◆ RWSynchObject() [1/3]
Enforces that this class be used only as a base class.
◆ RWSynchObject() [2/3]
Constructs a static instance, but does no direct initialization. The RWSynchObject is initialized on first use.
This constructor must be used only for static instances. Use of this constructor with an automatically or dynamically allocated instance produces errors or other unpredictable behavior.
Static instances are zero initialized, which results in an RWSynchObject with a cancellation state of RW_CANCELLATION_DISABLED.
◆ RWSynchObject() [3/3]
◆ disableCancellation()
void RWSynchObject::disableCancellation |
( |
| ) |
|
|
inline |
Turns off automatic cancellation detection.
◆ enableCancellation()
Turns on automatic cancellation detection.
◆ isCancellationEnabled()
bool RWSynchObject::isCancellationEnabled |
( |
| ) |
const |
|
inline |
Returns true
if automatic cancellation is enabled, otherwise false
.
◆ operator=()
◆ setCancellation()
Turns on automatic cancellation detection.
◆ testCancellation()
void RWSynchObject::testCancellation |
( |
| ) |
|
|
inlineprotected |
Invokes a cancellation method if one has been registered, otherwise does nothing.
◆ RW_CANCELLATION_DISABLED
#define RW_CANCELLATION_DISABLED |
|
related |
Flag to specify cancellation state.
◆ RW_CANCELLATION_ENABLED
#define RW_CANCELLATION_ENABLED |
|
related |
◆ RWCancellationState
typedef void(* RWCancellationState) () |
|
related |
◆ rwServiceCancellation()
void rwServiceCancellation |
( |
void | | ) |
|
|
related |
This function determines the calling thread's current runnable, if any, and calls RWRunnableSelf::serviceCancellation() on that runnable. If cancellation has been requested on the runnable object, then an RWCancellation exception is thrown.
Note that this function looks up the current runnable every time it is called. If you need to service cancellation repeatedly, e.g., within a loop, it is more efficient to call the global function rwRunnable() to get an RWRunnableSelf handle for the current runnable, and then call RWRunnableSelf::serviceCancellation() directly on this handle instance each time.
- See also
- RWCancellation, RWRunnableSelf, rwRunnable()