SourcePro® API Reference Guide

 
List of all members | Public Member Functions | Protected Member Functions | Related Functions
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 (RWCancellationState state=0)
 
 RWSynchObject (RWStaticCtor)
 
 RWSynchObject (const RWSynchObject &second)
 
RWSynchObjectoperator= (const RWSynchObject &second)
 
void testCancellation ()
 

Related Functions

(Note that these are not member functions.)

#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::RWSynchObject ( RWCancellationState  state = 0)
inlineprotected

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

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::RWSynchObject ( const RWSynchObject second)
inlineprotected

Copy constructor.

Member Function Documentation

void RWSynchObject::disableCancellation ( )
inline

Turns off automatic cancellation detection.

void RWSynchObject::enableCancellation ( RWCancellationState  state)
inline

Turns on automatic cancellation detection.

bool RWSynchObject::isCancellationEnabled ( ) const
inline

Returns true if automatic cancellation is enabled, otherwise false.

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

Assignment operator.

void RWSynchObject::setCancellation ( RWCancellationState  state)
inline

Turns on automatic cancellation detection.

void RWSynchObject::testCancellation ( )
inlineprotected

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

Friends And Related Function Documentation

#define RW_CANCELLATION_DISABLED
related

Flag to specify cancellation state.

#define RW_CANCELLATION_ENABLED
related

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

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
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 © 2023 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.