Global Functions and Macros
#include <rw/thread/rwtMakeRunnableGuard.h>
An RWRunnableGuard is a special functor that is designed for use with the RWGuardedRunnableQueue class and the runnable server classes RWRunnableServer and RWServerPool, which use a guarded runnable queue internally. A runnable guard functor is used by the RWGuardedRunnableQueue class to select the next enqueued run-nable to execute. It is designed to allow a runnable to remain in a queue until some condition is satisfied.
When a client requests a runnable from a runnable queue, the queue selects the next runnable to execute by traversing any enqueued runnables, and executing their guard functors, until it finds a runnable whose guard functor evaluates to TRUE. That runnable is then returned to the client.
#include <iostream.h> #include<rw/thread/RWRunnableFunction.h> #include<rw/thread/RWRunnableServer.h> #include<rw/thread/rwtMakeRunnableFunction.h> #include<rw/thread/RWRunnableGuard.h> void something(){ cout << "I'm a runnable" << endl; } class YourClass{ public: RWBoolean yourFunc(){ if(/*some condition*/) return TRUE; else return FALSE; } }; int main(){ RWRunnableServer runnableServer(RWRunnableServer::make()); runnableServer.start(); RWRunnableFunction doSomething; doSomething = rwtMakeRunnableFunction(something); YourClass yourClass; // Construct a guard functor using a template function. RWRunnableGuard guard1; guard1 = rwtMakeRunnableGuard(yourClass, &YourClass::yourFunc); runnableServer.enqueue(doSomething, guard1); // Construct a guard functor using a macro. RWRunnableGuard guard2; guard2 = rwtMakeRunnableGuardM(YourClass, yourClass, RWBoolean, &YourClass::yourFunc); runnableServer.enqueue(doSomething, guard2); runnableServer.stop(); runnableServer.join(); return 0; }
typedef RWTFunctorR0<RWBoolean>RWRunnableGuard
The function templates in this section use the following naming conventions for their arguments:
DR | Type name of the function return value. For runnable guards the return must be convertible to RWBoolean. |
Callee | Name of the class of a member function used as a runnable guard. |
callee | Class instance bound to the member function used as a runnable guard. |
function | Name of the function, member or otherwise, to be used as a runnable guard. |
A1 | Type of the first callee argument accepted by the runnable guard function. |
AA1 | Type name of the first caller argument passed to the runnable guard, at the creation of the runnable guard instance. |
a1 | Value of the first caller argument passed to a runnable guard instance at its creation. |
A2 | Type name of the second callee argument accepted by the runnable guard function. |
AA2 | Type name of the second caller argument passed to the runnable guard, at the creation of the runnable guard instance. |
a2 | Value of the second caller argument passed to a runnable guard instance at its creation. |
A3 | Type of the third callee argument accepted by the runnable guard function. |
AA3 | Type name of the third caller argument passed to the runnable guard, at the creation of the runnable guard instance. |
a3 | Value of the third caller argument passed to a runnable guard instance at its creation. |
template <class DR> RWRunnableGuard rwtMakeRunnableGuard(DR (*function)(void));
Creates an RWRunnableGuard to call function(), which returns DR.
template <class DR, class A1, class AA1> RWRunnableGuard rwtMakeRunnableGuard(DR (*function)(A1),AA1 a1);
Creates an RWRunnableGuard to call function(a1), which returns DR.
template <class DR, class A1, class A2, class AA1, class AA2> RWRunnableGuard rwtMakeRunnableGuard(DR (*function)(A1,A2),AA1 a1,AA2 a2);
Creates an RWRunnableGuard to call function(a1,a2), which returns DR.
template <class DR, class A1, class A2, class A3, class AA1, class AA2, class AA3> RWRunnableGuard rwtMakeRunnableGuard(DR (*function)(A1,A2,A3),AA1 a1, AA2 a2,AA3 a3);
Creates an RWRunnableGuard to call function(a1,a2,a3), which returns DR.
template <class Callee, class DR> RWRunnableGuard rwtMakeRunnableGuard(Callee& callee, DR(Callee::*function)(void));
Creates an RWRunnableGuard to call callee.function(), which returns DR.
template <class Callee, class DR, class A1, class AA1> RWRunnableGuard rwtMakeRunnableGuard(Callee& callee, DR(Callee::*function)(A1), AA1 a1);
Creates an RWRunnableGuard to call callee.function(a1), which returns DR.
template <class Callee, class DR, class A1, class AA1,
class A2, class AA2> RWRunnableGuard rwtMakeRunnableGuard(Callee& callee, DR(Callee::*function)(A1,A2), AA1 a1, AA2 a2);
Creates an RWRunnableGuard to call callee.function(a1,a2), which returns DR.
template <class Callee, class DR, class A1,
class AA1, class A2, class AA2, class A3, class AA3> RWRunnableGuard rwtMakeRunnableGuard(Callee& callee, DR (Callee::*function)(A1,A2,A3), AA1 a1, AA2 a2, AA3 a3);
Creates an RWRunnableGuard to call callee.function(a1,a2,a3), which returns DR.
The macros in this section use the following naming conventions for the macro arguments:
DR | Type name of the function return value. For runnable guards, the return type is an RWBoolean. |
function | Global function pointer. |
A1 | Type name of the first argument. |
a1 | Expression that can be converted to an instance of A1. |
A2 | Type name of the second argument. |
a2 | Expression that can be converted to an instance of A2. |
A3 | Type name of the third argument. |
a3 | Expression that can be converted to an instance of A3. |
rwtMakeRunnableGuardG(DR,function)
Creates an RWRunnableGuard set to call function().
rwtMakeRunnableGuardGA1(DR,function,A1,a1)
Creates an RWRunnableGuard set to call function(a1).
rwtMakeRunnableGuardGA2(DR,function,A1,a1,A2,a2)
Creates an RWRunnableGuard set to call function(a1,a2).
rwtMakeRunnableGuardGA3(DR,function,A1,a1,A2,a2,A3,a3)
Creates an RWRunnableGuard set to call function(a1,a2,a3).
The macros in this section use the following naming conventions for the macro arguments:
Callee | Type name of the function's class. |
callee | Expression that results in a pointer to a Callee instance. |
DR | Type name of the function return value. For runnable guards DR is an RWBoolean. |
function | Reference to a member function of class Callee. |
A1 | Type name of the first argument. |
a1 | Expression that can be converted to an instance of A1. |
A2 | Type name of the second argument. |
a2 | Expression that can be converted to an instance of A2. |
A3 | Type name of the second argument. |
a3 | Expression that can be converted to an instance of A3. |
rwtMakeRunnableGuardM(Callee,callee,DR,function)
Creates an RWRunnableGuard set to call callee.function().
rwtMakeRunnableGuardMA1(Callee,callee,DR,function,A1,a1)
Creates an RWRunnableGuard set to call callee.function(a1).
rwtMakeRunnableGuardMA2(Callee,callee,DR,function,A1,a1,A2,a2)
Creates an RWRunnableGuard set to call callee.function(a1,a2).
rwtMakeRunnableGuardMA3(Callee,callee,DR, function,A1,a1,A2,a2,A3,a3)
Creates an RWRunnableGuard set to call callee.function(a1,a2,a3).
RWGuardedRunnableQueue, RWRunnableServer, RWServerPool
©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.