SourcePro® 2024.1 |
SourcePro® API Reference Guide |
Handle class for functor-based, runnable objects. More...
#include <rw/thread/RWRunnableFunction.h>
Public Member Functions | |
RWRunnableFunction () | |
RWRunnableFunction (const RWRunnableFunction &second) | |
RWRunnableFunction (RWStaticCtor) | |
~RWRunnableFunction () | |
RWTFunctor< void()> | getFunctor () const |
RWRunnableFunction & | operator= (const RWRunnableFunction &second) |
void | setFunctor (const RWTFunctor< void()> &functor) |
Public Member Functions inherited from RWRunnable | |
RWRunnable () | |
RWRunnable (const RWRunnable &second) | |
RWRunnable (RWStaticCtor) | |
~RWRunnable () | |
RWRunnable | getNestedRunnable () const |
RWRunnableSelf | getRWRunnableSelf () const |
RWWaitStatus | join (unsigned long milliseconds) |
void | join (void) |
RWRunnable & | operator= (const RWRunnable &second) |
void | raise () const |
void | releaseInterrupt () |
RWWaitStatus | requestCancellation () |
RWWaitStatus | requestCancellation (unsigned long milliseconds) |
RWWaitStatus | requestInterrupt () |
RWWaitStatus | requestInterrupt (unsigned long milliseconds) |
RWCompletionState | start () |
RWExecutionState | wait (unsigned long stateMask) |
RWWaitStatus | wait (unsigned long stateMask, RWExecutionState *state, unsigned long milliseconds) |
Public Member Functions inherited from RWRunnableHandle | |
void | addCallback (const RWTFunctor< void(const RWRunnable &, RWExecutionState)> &functor, unsigned long stateMask, RWCallbackScope scope=RW_CALL_REPEATEDLY) |
RWCompletionState | getCompletionState () const |
RWExecutionState | getExecutionState () const |
bool | isInterruptRequested () const |
bool | isSelf () const |
bool | isSelf (const RWThreadId &id) const |
void | removeCallback (const RWTFunctor< void(const RWRunnable &, RWExecutionState)> &functor) |
RWThreadId | threadId () const |
Public Member Functions inherited from RWHandleBase | |
bool | isValid (void) const |
bool | operator!= (const RWHandleBase &second) const |
bool | operator== (const RWHandleBase &second) const |
Static Public Member Functions | |
static RWRunnableFunction | make () |
static RWRunnableFunction | make (const RWTFunctor< void()> &functor) |
Additional Inherited Members | |
Protected Member Functions inherited from RWRunnable | |
RWRunnable (const RWRunnableSelf &second) | |
Protected Member Functions inherited from RWRunnableHandle | |
RWRunnableHandle () | |
RWRunnableHandle (const RWRunnableHandle &second) | |
RWRunnableHandle (RWRunnableImp *runnableImpP) | |
RWRunnableHandle (RWStaticCtor) | |
~RWRunnableHandle () | |
RWRunnableHandle & | operator= (const RWRunnableHandle &second) |
Protected Member Functions inherited from RWHandleBase | |
RWHandleBase (const RWHandleBase &second) | |
RWHandleBase (RWBodyBase *body) | |
RWHandleBase (RWStaticCtor) | |
RWHandleBase (void) | |
~RWHandleBase (void) | |
RWBodyBase & | body (void) const |
RWHandleBase & | operator= (const RWHandleBase &second) |
The RWRunnableFunction class is a handle class for 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-based 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, which executes the specified functor in the same thread that calls start().
|
inline |
Constructs an empty RWRunnableFunction handle instance.
|
inline |
Constructs a global static handle instance that may be assigned to before construction. The static constructor does not change the instance state.
|
inline |
Binds a new handle to the runnable instance, if any, pointed to by the handle second.
|
inline |
Destructor.
RWTFunctor< void()> RWRunnableFunction::getFunctor | ( | ) | const |
Gets the current functor instance, if any, associated with the runnable. Possible exceptions include RWTHRInvalidPointer and RWTHRInternalError.
|
static |
Constructs and returns an RWRunnableFunction 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.
|
inline |
Binds this
to the runnable instance, if any, pointed to by the handle second.
void RWRunnableFunction::setFunctor | ( | const RWTFunctor< void()> & | functor | ) |
Sets the functor to be executed by this runnable. Possible exceptions include RWTHRInvalidPointer and RWTHRInternalError.
Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |