rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWRunnableHandle Class Reference
[Threading]

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

List of all members.

Public Member Functions

void addCallback (const RWTFunctor2< 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 RWTFunctor2< const RWRunnable &, RWExecutionState > &functor)
RWThreadId threadId () const

Protected Member Functions

 RWRunnableHandle ()
 RWRunnableHandle (RWStaticCtor)
 RWRunnableHandle (RWRunnableImp *runnableImpP)
 RWRunnableHandle (const RWRunnableHandle &second)
 ~RWRunnableHandle ()
RWRunnableHandleoperator= (const RWRunnableHandle &second)
RWRunnableImp & body (void) const

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 (  )  [inline, protected]

Constructs an empty (invalid) handle instance.

RWRunnableHandle::RWRunnableHandle ( RWStaticCtor   )  [inline, protected]

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  )  [inline, protected]

Copy constructor.

RWRunnableHandle::~RWRunnableHandle (  )  [inline, protected]

Destructor.


Member Function Documentation

void RWRunnableHandle::addCallback ( const RWTFunctor2< 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.

RWRunnableImp& RWRunnableHandle::body ( void   )  const [protected]

Gets a reference for the body instance, if any.

Exceptions:
RWTHRInvalidPointer Thrown if this handle is not attached to a body.

Reimplemented from RWHandleBase.

Reimplemented in RWRunnableFunction, RWRunnableServer, RWServerPool, RWThread, RWThreadFunction, and RWThreadSelf.

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 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.

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.

RWRunnableHandle & RWRunnableHandle::operator= ( const RWRunnableHandle second  )  [inline, protected]

Assignment operator.

void RWRunnableHandle::removeCallback ( const RWTFunctor2< 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.

 All Classes Functions Variables Typedefs Enumerations Enumerator Friends

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.