SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
RWSynchObject Class Reference

Base class for synchronization classes. More...

#include <rw/sync/RWSynchObject.h>

Inheritance diagram for RWSynchObject:
RWCondition RWCriticalSection RWFIFOMutexLock RWMutexLock RWNullMutexLock RWReadersWriterLock RWSemaphore RWTRecursiveLock< Mutex >

Public Member Functions

void disableCancellation ()
 
void enableCancellation (RWCancellationState)
 
bool isCancellationEnabled () const
 
void setCancellation (RWCancellationState)
 

Protected Member Functions

 RWSynchObject (const RWSynchObject &second)
 
 RWSynchObject (RWCancellationState state=0)
 
 RWSynchObject (RWStaticCtor)
 
RWSynchObjectoperator= (const RWSynchObject &second)
 
void testCancellation ()
 

Related Symbols

(Note that these are not member symbols.)

#define RW_CANCELLATION_DISABLED
 
#define RW_CANCELLATION_ENABLED
 
typedef void(* RWCancellationState) ()
 
void rwServiceCancellation (void)
 

Detailed Description

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

Constructor & Destructor Documentation

◆ RWSynchObject() [1/3]

RWSynchObject::RWSynchObject ( RWCancellationState state = 0)
inlineprotected

Enforces that this class be used only as a base class.

◆ RWSynchObject() [2/3]

RWSynchObject::RWSynchObject ( RWStaticCtor )
inlineprotected

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]

RWSynchObject::RWSynchObject ( const RWSynchObject & second)
inlineprotected

Copy constructor.

Member Function Documentation

◆ disableCancellation()

void RWSynchObject::disableCancellation ( )
inline

Turns off automatic cancellation detection.

◆ enableCancellation()

void RWSynchObject::enableCancellation ( RWCancellationState state)
inline

Turns on automatic cancellation detection.

◆ isCancellationEnabled()

bool RWSynchObject::isCancellationEnabled ( ) const
inline

Returns true if automatic cancellation is enabled, otherwise false.

◆ operator=()

RWSynchObject & RWSynchObject::operator= ( const RWSynchObject & second)
inlineprotected

Assignment operator.

◆ setCancellation()

void RWSynchObject::setCancellation ( RWCancellationState state)
inline

Turns on automatic cancellation detection.

◆ testCancellation()

void RWSynchObject::testCancellation ( )
inlineprotected

Invokes a cancellation method if one has been registered, otherwise does nothing.

Friends And Related Symbol Documentation

◆ RW_CANCELLATION_DISABLED

#define RW_CANCELLATION_DISABLED
related

Flag to specify cancellation state.

◆ RW_CANCELLATION_ENABLED

#define RW_CANCELLATION_ENABLED
related

Flag to specify cancellation state, defined in the Threading package as &rwServiceCancellation.

◆ RWCancellationState

typedef void(* RWCancellationState) ()
related

This function pointer type is used with the Synchronization objects to set the cancellation policy.

RW_CANCELLATION_DISABLED is defined in the Synchronization package to be 0. RW_CANCELLATION_ENABLED is defined in the Threading package as &rwServiceCancellation. Either macro may be passed where an RWCancellationState is expected. For example, see RWSynchObject::setCancellation(RWCancellationState).

For information on changes in RWCancellationState and compatibility with previous versions of Threads.h++, please see the Threads Module User's Guide.

See also
RWSynchObject

◆ 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()

Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.