SourcePro® API Reference Guide

 
List of all members | Public Member Functions | Protected Member Functions
RWRunnableHandle Class Reference

Base class from which all runnable object handles derive. More...

#include <rw/thread/RWRunnableHandle.h>

Inheritance diagram for RWRunnableHandle:
RWHandleBase RWRunnable RWRunnableSelf RWRunnableFunction RWThread RWTRunnableIOUFunction< Return > RWThreadSelf RWRunnableServer RWThreadFunction RWTThreadIOUFunction< Return > RWServerPool

Public Member Functions

void addCallback (const RWTFunctor< void(const RWRunnable &, RWExecutionState)> &functor, unsigned long stateMask, RWCallbackScope scope=RW_CALL_REPEATEDLY)
 
RWCompletionState getCompletionState () const
 
RWExecutionState getExecutionState () const
 
bool isInterruptRequested () const
 
bool isSelf () const
 
bool isSelf (const RWThreadId &id) const
 
void removeCallback (const RWTFunctor< void(const RWRunnable &, RWExecutionState)> &functor)
 
RWThreadId threadId () const
 
- Public Member Functions inherited from RWHandleBase
bool isValid (void) const
 
bool operator!= (const RWHandleBase &second) const
 
bool operator< (const RWHandleBase &second) const
 
bool operator== (const RWHandleBase &second) const
 

Protected Member Functions

 RWRunnableHandle ()
 
 RWRunnableHandle (RWStaticCtor)
 
 RWRunnableHandle (RWRunnableImp *runnableImpP)
 
 RWRunnableHandle (const RWRunnableHandle &second)
 
 ~RWRunnableHandle ()
 
RWRunnableHandleoperator= (const RWRunnableHandle &second)
 
- Protected Member Functions inherited from RWHandleBase
 RWHandleBase (void)
 
 RWHandleBase (RWStaticCtor)
 
 RWHandleBase (RWBodyBase *body)
 
 RWHandleBase (const RWHandleBase &second)
 
 ~RWHandleBase (void)
 
RWBodyBasebody (void) const
 
RWHandleBaseoperator= (const RWHandleBase &second)
 

Detailed Description

The RWRunnableHandle class is the base class for all runnable object handles.

A runnable object provides the basic mechanisms used to create, control, and monitor the threads of execution within your application. Runnables are used to define the task or activity to be performed by a thread.

Each runnable object is reference-counted; a runnable body instance keeps a count of the number of handles that currently reference it. A runnable object is deleted when the last handle that references the body is deleted.

The public interface for a runnable is provided by its handle classes. Many of the public functions in a handle simply forward control to a corresponding protected function in the body class. A runnable handle class instance may be empty. Any attempt to use an empty handle to access a runnable produces an RWTHRInvalidPointer exception.

The RWRunnableHandle class defines those functions that may be accessed from either inside or outside of a runnable. The RWRunnable class provides an interface for threads executing outside of a runnable. It defines the runnable member functions that may be executed only by an external thread. The thread executing inside of a runnable should access the runnable using the RWRunnableSelf handle class.

See also
RWRunnable, RWRunnableSelf

Constructor & Destructor Documentation

RWRunnableHandle::RWRunnableHandle ( )
inlineprotected

Constructs an empty (invalid) handle instance.

RWRunnableHandle::RWRunnableHandle ( RWStaticCtor  )
inlineprotected

Constructs a global static handle instance (may be used before constructed).

RWRunnableHandle::RWRunnableHandle ( RWRunnableImp *  runnableImpP)
protected

Constructs a runnable handle with the given implementation.

RWRunnableHandle::RWRunnableHandle ( const RWRunnableHandle second)
inlineprotected

Copy constructor.

RWRunnableHandle::~RWRunnableHandle ( )
inlineprotected

Destructor.

Member Function Documentation

void RWRunnableHandle::addCallback ( const RWTFunctor< void(const RWRunnable &, RWExecutionState)> &  functor,
unsigned long  stateMask,
RWCallbackScope  scope = RW_CALL_REPEATEDLY 
)

Adds a callback to the end of the state-change callback list. The mask parameter stateMask is used to choose the runnable state or states for which the callback is to be executed (see RWExecutionState). The scope argument determines whether the callback is called just once or repeatedly. Callbacks are called in FIFO order. Possible exceptions include RWTHRInvalidPointer and RWTHRInternalError.

RWCompletionState RWRunnableHandle::getCompletionState ( ) const

Queries the completion state of the runnable. Possible exceptions include RWTHRInvalidPointer and RWTHRInternalError.

RWExecutionState RWRunnableHandle::getExecutionState ( ) const

Queries the current execution state of the runnable. Possible exceptions include RWTHRInvalidPointer and RWTHRInternalError.

bool RWRunnableHandle::isInterruptRequested ( ) const

Queries the runnable to determine whether the runnable has an outstanding interrupt request. Possible exceptions include RWTHRInvalidPointer and RWTHRInternalError.

bool RWRunnableHandle::isSelf ( ) const

Indicates whether the calling thread is the same thread that is currently executing within this runnable. Possible exceptions include RWTHRInvalidPointer and RWTHRInternalError.

bool RWRunnableHandle::isSelf ( const RWThreadId id) const

Indicates whether the specified thread ID id refers to the thread that is currently executing within this runnable. Possible exceptions include RWTHRInvalidPointer and RWTHRInternalError.

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

Assignment operator.

void RWRunnableHandle::removeCallback ( const RWTFunctor< void(const RWRunnable &, RWExecutionState)> &  functor)

Removes all previously added callback entries that call the specified functor. This function locks the runnable object while removing the callback, and unlocks it when done. Possible exceptions include RWTHRInvalidPointer and RWTHRInternalError.

RWThreadId RWRunnableHandle::threadId ( ) const

Queries for the ID of the thread currently active within the runnable. The exception RWTHRThreadNotActive is thrown if there is no thread executing within the runnable. Possible exceptions include RWTHRInvalidPointer, RWTHRThreadNotActive, and RWTHRInternalError.

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