RWRunnableSelf RWRunnableHandle
getNestedRunnable() getRWRunnable() |
interrupt() operator=() |
serviceCancellation() serviceInterrupt() |
sleep() yield() |
#include <rw/thread/RWRunnableSelf.h>
The RWRunnableSelf class is a handle class for a runnable object.
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 RWRunnableSelf class provides an interface for the thread executing inside of a runnable. It defines the runnable member functions that may only be executed by the internal thread. Threads executing outside of a runnable should access the runnable using the RWRunnable handle class. The RWRunnableHandle class defines those functions that may be accessed from either inside or outside of a runnable.
To retrieve an RWRunnableSelf handle instance for the current runnable, use the rwRunnable() function. You may also convert an RWRunnable handle to an RWRunnableSelf handle by calling the member RWRunnable::getRunnableSelf(), but any attempt to violate the thread access restrictions imposed by the separate interfaces will generally result in an RWTHRIllegalAccess exception.
RWRunnableSelf(void);
Constructs an empty (invalid) handle instance.
RWRunnableSelf(RWStaticCtor);
Constructs a global static handle instance (may be assigned before it is constructed).
RWRunnableSelf(const RWRunnableSelf& second);
Copy constructor.
RWRunnableSelf& operator=(const RWRunnableSelf& second);
Assignment operator.
RWRunnable getRWRunnable(void) const;
Returns an external interface handle bound to the same runnable instance (if any) pointed to by this handle.
RWRunnableSelf getNestedRunnable(void) const;
Returns a handle to the nested runnable object, if any. Possible exceptions include RWTHRInvalidPointer and RWTHRInternalError.
void interrupt(void);
Interrupts the calling thread executing within the runnable until the runnable is released by another thread. Changes execution state to RW_THR_INTERRUPTED. Possible exceptions include RWTHRInvalidPointer, RWTHRInternalError, and RWTHRIllegalAccess.
void serviceCancellation(void);
Checks for cancellation requests, throwing an RWCancellation object if cancellation has been requested, and returning otherwise. May result in a change of execution state to RW_THR_CANCELING. Other possible exceptions include RWTHRInvalidPointer, RWTHRInternalError, and RWTHRIllegalAccess.
RWBoolean serviceInterrupt(void);
Checks for interrupt requests, blocking the calling thread if an interrupt has been requested and returning immediately if no interrupt requests are pending. May result in a change of execution state to RW_THR_INTERRUPTED. This function may only be called by an internal thread. Possible exceptions include RWTHRInvalidPointer, RWTHRInternalError, and RWTHRIllegalAccess.
void sleep(unsigned long milliseconds);
Causes the calling thread, executing within the runnable, to sleep for the specified time period yielding execution to other threads. Temporarily changes the execution state to RW_THR_SLEEPING while sleeping, then restores the previous execution state. The global function rwSleep() may be used instead of this function, but rwSleep() does not produce any execution state changes in a runnable instance while this member does. Possible exceptions include RWTHRInvalidPointer, RWTHRInternalError, and RWTHRIllegalAccess.
void yield(void);
Causes the calling thread, executing within the runnable, to yield execution to other threads. Temporarily changes the execution state to RW_THR_YIELDING, and then restores the previous execution state. The global function rwYield() may be used instead of this function, but rwYield() does not produce any execution state changes in a runnable instance while this member does. Possible exceptions include RWTHRInvalidPointer, RWTHRInternalError, and RWTHRIllegalAccess.
RWRunnable, RWRunnableFunction, RWTRunnableIOUFunction, RWRunnableServer, RWServerPool, RWThread, RWThreadFunction, RWTThreadIOUFunction
©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.