SourcePro® 2022.1 |
SourcePro® API Reference Guide |
Handle class for functor-based threaded runnable objects. More...
#include <rw/thread/RWThreadFunction.h>
Static Public Member Functions | |
static RWThreadFunction | make () |
static RWThreadFunction | make (const RWTFunctor< void()> &functor) |
static RWThreadFunction | make (const RWTFunctor< void()> &functor, const RWThreadAttribute &attr) |
static RWThreadFunction | make (const RWThreadAttribute &attr) |
Static Public Member Functions inherited from RWThread | |
static bool | canGetMaxThreads () |
static bool | canSuspendResume () |
static size_t | getMaxThreads () |
Additional Inherited Members | |
Protected Member Functions inherited from RWThread | |
RWThread (RWThreadImp *threadImpP) | |
Protected Member Functions inherited from RWRunnable | |
RWRunnable (const RWRunnableSelf &second) | |
Protected Member Functions inherited from RWRunnableHandle | |
RWRunnableHandle () | |
RWRunnableHandle (RWStaticCtor) | |
RWRunnableHandle (RWRunnableImp *runnableImpP) | |
RWRunnableHandle (const RWRunnableHandle &second) | |
~RWRunnableHandle () | |
RWRunnableHandle & | operator= (const RWRunnableHandle &second) |
Protected Member Functions inherited from RWHandleBase | |
RWHandleBase (void) | |
RWHandleBase (RWStaticCtor) | |
RWHandleBase (RWBodyBase *body) | |
RWHandleBase (const RWHandleBase &second) | |
~RWHandleBase (void) | |
RWBodyBase & | body (void) const |
RWHandleBase & | operator= (const RWHandleBase &second) |
The RWThreadFunction class is a handle class for 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 that encapsulates 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.
RWThreadFunction is used to access a threaded runnable, which creates a new thread to execute the specified functor.
|
inline |
Constructs an empty RWThreadFunction handle instance.
|
inline |
Binds a new handle to the runnable instance, if any, pointed to by the handle second.
|
inline |
Destructor.
RWTFunctor<void()> RWThreadFunction::getFunctor | ( | ) | const |
Gets the current functor instance, if any, associated with the runnable.
Possible exceptions include RWTHRInvalidPointer and RWTHRInternalError.
|
static |
Constructs and returns an RWThreadFunction object with an undefined functor. The setFunctor() member must be used to define a functor prior to starting.
|
static |
Constructs and returns an RWRunnableFunction that executes the specified functor when started.
|
static |
Constructs and returns an RWRunnableFunction that executes the specified functor when started. A new thread is created using the thread attributes given by attr.
|
static |
Constructs and returns an RWThreadFunction object with an undefined functor. The setFunctor() member must be used to define a function prior to starting. A new thread is created using the attributes given by attr.
|
inline |
Binds this
to the runnable instance, if any, pointed to by the handle second.
void RWThreadFunction::setFunctor | ( | const RWTFunctor< void()> & | functor | ) |
Sets the functor to be executed by this runnable.
Possible exceptions include RWTHRInvalidPointer and RWTHRInternalError.
Copyright © 2022 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |