Rogue Wave banner
Previous fileTop of DocumentContentsIndexNext file

RWRunnableFunction


RWRunnableFunction RWRunnable

Data Type and Member Function Indexes
(exclusive of constructors and destructors)

Member Functions

Package

Threading

Header File

#include <rw/thread/RWRunnableFunction.h> 

Description

The RWRunnableFunction class is a handle class for a functor-based runnable objects.

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.

A functor-based runnable accepts a functor object for execution. A functor is an object used to encapsulate a function call. Each functor keeps a pointer to the function and copies of the argument values that are to be passed to the function. Invoking a functor produces a call to the function.

A functor-based runnable simply redefines the basic run() member to invoke a functor instance stored within the runnable. With this capability, you do not have to resort to sub-classing or other intrusive techniques to customize the execution behavior of a runnable. The functor-base runnables allow you to dynamically specify the functions you want to execute when a runnable is started.

RWRunnableFunction is used to access a synchronous runnable. A synchronous runnable executes the specified functor using in same thread that calls start().

Although functors are central to the inner workings of the Threading package, you may not need to deal with functors directly. Instead, the rwtMakeRunnableFunction() global template functions and macros can build the appropriate functor instance and use it to initialize an RWRunnableFunction object directly from a function pointer.

Example

Public Constructors

RWRunnableFunction(void);
RWRunnableFunction(RWStaticCtor);
RWRunnableFunction(const RWRunnableFunction& second);

Public Member Operator

RWRunnableFunction&
operator=(const RWRunnableFunction& second);

Public Member Functions

RWFunctor0
getFunctor(void) const;
void
setFunctor(const RWFunctor0& functor);

Public Static Member Functions

static RWRunnableFunction
make(void);
static RWRunnableFunction
make(const RWFunctor0& functor);

See Also

rwtMakeRunnableFunction, RWFunctor0, RWRunnable, RWThreadFunction



Previous fileTop of DocumentContentsIndexNext file

©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.