Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Threads Module Reference Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

RWRunnableTrap

Module:  Threads   Package:  Threading


RWRunnableTrap RWHandleBase

Local Index

Members

Header File

#include <rw/thread/RWRunnableTrap.h> 

Description

RWRunnableTrap allows you to wait for a number of runnables or threads to reach a certain execution state. When you create an RWRunnableTrap you specify the target execution state. This causes any runnable that the trap has been set on to catch the runnable when it reaches the given execution state.

Another thread can get each runnable as it reaches the target execution state by calling the getNext() function of the runnable trap. A runnable may be caught by the trap by calling setTrap() and passing in the target runnable. By default the runnable is caught only once, the first time that it enters the execution state. When you set the trap on a runnable you may specify that the runnable be caught repeatedly, each time that it enters the execution state.

A common usage of an RWRunnableTrap is to wait for a number of threads to complete execution. This allows you to launch and wait for multiple threads without having to keep track of those threads in an array or other data structure. After a thread is created, but before it is started, it can be added to a runnable trap.

The default target execution state is RW_THR_INITIAL which is the state that a runnable reaches when it completes execution.

Example

Static Member Functions

static
RWRunnableTrap
make(unsigned long executionStateMask=RW_THR_INITIAL);

Public Constructors

RWRunnableTrap();
RWRunnableTrap(RWStaticCtor);
RWRunnableTrap(const RWRunnableTrap& second);

Public Destructor

~RWRunnableTrap();

Public Member Operator

RWRunnableTrap&
operator=(const RWRunnableTrap& second);

Public Member Functions

RWRunnable 
getNext();
RWWaitStatus
getNext(RWRunnable &r, unsigned long milliseconds);
void 
getNext(RWRunnable& r, RWExecutionState& es);
RWWaitStatus
getNext(RWRunnable& r, RWExecutionState& es, 
        unsigned long milliseconds);
bool 
isEmpty() const;
void
setTrap(RWRunnable runnable, 
        RWCallbackScope scope=RW_CALL_ONCE);
bool
tryGetNext(RWRunnable& runnable);
bool
tryGetNext(RWRunnable& runnable, RWExecutionState& es);

Protected Constructor

RWRunnableTrap(RWRunnableTrapImp* runnableTrapImpP);

See Also

RWRunnable



Previous fileTop of DocumentContentsIndex pageNext file

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