Execution Nesting
When an active runnable starts a second, synchronous runnable, the second runnable is executing or nested inside the first. Each runnable that is executing a nested runnable maintains an internal reference or link to that runnable. These links are traversed to find the innermost runnable currently executing under a thread.
Execution nesting is implemented by the following functions:
RWRunnable RWRunnableSelf::getNestedRunnable(void) const RWRunnableSelf RWRunnable::getNestedRunnable(void) const RWRunnableSelf rwRunnable(void) RWThreadSelf rwThread(void) The
rwThread() function can be used to get a handle to the threaded runnable that originated the calling thread. If the calling thread was not started by a Threading package runnable class, as is the case with the main thread, then the handle returned by this function is empty. Whenever the source of a thread is in question, you should use the
isValid() function to test the handle returned by
rwThread() before using it, as shown
Example 19.
Example 19 – Testing the source of a thread
RWThreadSelf thread = rwThread();
if (thread.isValid()) {
// OK, this thread was created by a runnable
}