RWRunnableHandle RWHandleBase
addCallback() getCompletionState() |
getExecutionState() isInterruptRequested() |
isSelf() operator=() |
removeCallback() threadId() |
#include <rw/thread/RWRunnableHandle.h>
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 will produce 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 only be executed by an external thread. The thread executing inside of a runnable should access the runnable using the RWRunnableSelf handle class.
enum RWExecutionState
For a description of this global enumerator, which is defined in RWRunnableHandle.h, see the entry for RWExecutionState.
enum RWCompletionState {
For a description of this global enumerator, which is defined in RWRunnableHandle.h, see the entry for RWCompletionState.
void 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 value is used to choose the runnable state or states for which the callback is to be executed (see RWExecutionState under RWRunnable). 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 getCompletionState(void) const;
Queries the completion state of the runnable. Possible exceptions include RWTHRInvalidPointer and RWTHRInternalError.
RWExecutionState getExecutionState(void) const;
Queries the current execution state of the runnable. Possible exceptions include RWTHRInvalidPointer and RWTHRInternalError.
RWBoolean isInterruptRequested(void) const;
Queries the runnable to determine whether the runnable has an outstanding interrupt request. Possible exceptions include RWTHRInvalidPointer and RWTHRInternalError.
RWBoolean isSelf(void) const;
Indicates whether the calling thread is the same thread that is currently executing within this runnable. Possible exceptions include RWTHRInvalidPointer and RWTHRInternalError.
RWBoolean isSelf(const RWThreadId& id) const;
Indicates whether the specified thread ID refers to the thread that is currently executing within this runnable. Possible exceptions include RWTHRInvalidPointer and RWTHRInternalError.
void 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 threadId(void) 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.
RWRunnableHandle(void);
Constructs an empty (invalid) handle instance.
RWRunnableHandle(RWStaticCtor);
Constructs a global static handle instance (may be used before constructed).
RWRunnableHandle(RWRunnableImp* runnableImpP);
Constructs a runnable handle with the given implementation.
RWRunnableHandle(const RWRunnableHandle& second);
Copy constructor.
RWRunnableHandle& operator=(const RWRunnableHandle& second);
Assignment operator.
©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.