Distinguishing Between Synchronous and Threaded Runnables
The completion state value returned from the start() function can be used to distinguish between a synchronous runnable and a threaded runnable, as shown in Example 5. The start() function on a synchronous runnable always returns a completion state of RW_THR_NORMAL, RW_THR_FAILED, or RW_THR_CANCELED. Threaded runnables always return RW_THR_PENDING.
Example 5 – Using completion state to distinguish synchronous from threaded runnables
void executeRunnable(RWRunnable& runnable)
{
RWCompletionState result;
if (RW_THR_PENDING == (result = runnable.start())) {
// Threaded Runnable
...
}
else {
// Synchronous Runnable
...
}
}