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

RWTThreadIOUFunction<Return>

Module:  Threads   Package:  Threading


RWTThreadIOUFunction<Return> RWThread

Local Index

Members

Header File

#include <rw/thread/RWTThreadIOUFunction.h> 

Description

The RWTThreadIOUFunction class is a handle class for a functor-based threaded 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 threaded 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, and in this case, a return value.

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.

RWTThreadIOUFunction is used to access a threaded runnable, which creates a new thread to execute the specified functor. The result of the functor is returned in the form of an IOU. An IOU may be obtained as soon as the runnable is created. To get the actual result from the IOU you must redeem it, and at that time if the result has not yet been calculated, then the calling thread will block until it has.

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

Example

Static Member Functions

static RWTThreadIOUFunction<Return>
make();
static RWTThreadIOUFunction<Return>
make(const RWTFunctorR0<Return>& functor);
static RWTThreadIOUFunction<Return>
make(const RWTIOUEscrow<Return>& escrow,
     const RWTFunctorR0<Return>& functor);
static RWTThreadIOUFunction<Return>
make(const RWTFunctorR0<Return>& functor,
     const RWThreadAttribute& attr);
static RWTThreadIOUFunction<Return>
make(const RWTIOUEscrow<Return>& escrow,
     const RWTFunctorR0<Return>& functor,
     const RWThreadAttribute& attr);

Public Constructors

RWTThreadIOUFunction();
RWTThreadIOUFunction(const RWTThreadIOUFunction<Return>& second);

Public Destructor

~RWTThreadIOUFunction()

Public Member Operators

RWTThreadIOUFunction<Return>&
operator=(const RWTThreadIOUFunction<Return>& second);
RWTIOUResult<Return>&
operator()() const;

Public Member Functions

RWTFunctorR0<Return>
getFunctor() const;
RWTIOUResult<Return>
result() const;
void
setFunctor(const RWTFunctorR0<Return>& functor);
void
setIOUEscrow(const RWTIOUEscrow<Return>& escrow);

See Also

rwtMakeThreadIOUFunction(), RWTFunctorR0, RWThread, RWRunnable, RWRunnableHandle, RWThreadAttribute



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.