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

rwtMakeRunnableFunction()

Module:  Threads   Package:  Threading


Global Functions and Macros

Local Index

Members

Non-Members

Header File

#include <rw/thread/rwtMakeRunnableFunction.h>

Description

rwtMakeRunnableFunction() creates an instance of RWRunnableFunction directly from a global or member function pointer. The easiest way to create a runnable object with the Threads Module is to begin with rwtMakeRunnableFunction(). By supplying a global or member function pointer you control what your runnable will do after starting. If you wish your runnable to start by calling a function that takes arguments, rwtMakeRunnableFunction() allows you to specify the values that should be passed to that function. Note that runnables created with rwtMakeRunnableFunction() will ignore any return values from the associated function. To create runnables from which you can extract a return value, see rwtMakeRunnableIOUFunction().

rwtMakeRunnableFunction() comes in two flavors. First, there is a set of overloaded global function templates. Since not all compilers are able to handle templates to the degree required by these functions, we also provide a corresponding set of macros. The template functions are slightly easier to use and you only have to remember one name. The macros are more portable but they do require more arguments; and as we cannot overload macros, each must have a unique name.

In naming the macros we have employed a convention to make the names easier to remember. Each name begins with rwtMakeRunnableFunction(), which will be followed by either a G if the macro is expecting a global function, or an M if it is expecting a member function. At that point the name is complete if the associated global or member function takes no arguments. Otherwise we add one of A1, A2, or A3 for functions with 1, 2, or 3 arguments respectively. For example, you will use macro rwtMakeRunnableFunctionG() to create a runnable that calls a global function that takes no arguments. The macro rwtMakeRunnableFunctionMA2() will create a runnable that calls a member function that takes two arguments.

Example Using Templates

Example Using Macros

Global Function Templates

template <class R>
RWRunnableFunction 
rwtMakeRunnableFunction(R (*function)(void))
template <class R, class A1, class AA1>
RWRunnableFunction 
rwtMakeRunnableFunction(R (*function)(A1), AA1 a1)
template <class R, class A1, class A2, class AA1, class AA2>
RWRunnableFunction 
rwtMakeRunnableFunction(R (*function)(A1,A2), AA1 a1, AA2 a2)
template <class R, class A1, class A2, class A3,            class AA1, class AA2, class AA3>
RWRunnableFunction 
rwtMakeRunnableFunction(R (*function)(A1,A2,A3), 
AA1 a1, AA2 a2,AA3 a3)
template <class Callee, class R>
RWRunnableFunction 
rwtMakeRunnableFunction(Callee& callee,
R (Callee::*function)(void))
template <class Callee, class R, class A1, class AA1>
RWRunnableFunction
rwtMakeRunnableFunction(Callee& callee,
R (Callee::*function)(A1), AA1 a1)
template <class Callee, class R, class A1, class A2, 
class AA1, class AA2> RWRunnableFunction rwtMakeRunnableFunction(Callee& callee,
R (Callee::*function)(A1,A2), AA1 a1, AA2 a2)
template <class Callee, class R, class A1, class A2, class A3, 
class AA1, class AA2, class AA3> RWRunnableFunction rwtMakeRunnableFunction(Callee& callee,
R (Callee::*function)(A1,A2,A3), AA1 a1, AA2 a2, AA3 a3)

Macros (for Use With Global Functions)

The macros in this section use the following naming conventions for the macro arguments:

rwtMakeRunnableFunctionG(R,function)
rwtMakeRunnableFunctionGA1(R,function,A1,a1)
rwtMakeRunnableFunctionGA2(R,function,A1,a1,A2,a2)
rwtMakeRunnableFunctionGA3(R,function,A1,a1,A2,a2,A3,a3)

Macros (for Use With Member Functions)

The macros in this section use the following naming conventions for the macro arguments:

rwtMakeRunnableFunctionM(Callee,callee,R,function) 
rwtMakeRunnableFunctionMA1(Callee,callee,R,function,A1,a1) 
rwtMakeRunnableFunctionMA2(Callee,callee,R,function,A1,a1,
                          A2,a2) 
rwtMakeRunnableFunctionMA3(Callee,callee,R,function,
A1,a1,A2,a2,A3,a3)

See Also

RWRunnableFunction



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.