Module: Threads Package: Threading
Global Functions and Macros
rwtMakeRunnableGuardM() |
rwtMakeRunnableGuardMA1() |
rwtMakeRunnableGuardMA2() |
rwtMakeRunnableGuardMA3() |
RWTFunctorR0 rwtMakeRunnableGuard() |
rwtMakeRunnableGuardG() rwtMakeRunnableGuardGA1() |
rwtMakeRunnableGuardGA2() rwtMakeRunnableGuardGA3() |
#include <rw/thread/rwtMakeRunnableGuard.h>
An RWRunnableGuard is a typedef to a functor used in conjection with the RWTPCValBufferBaseGuarded and derived classes, templatized on a RWRunnable. The runnable server classes RWRunnableServer and RWServerPool use these functors internally. A runnable guard functor is used by the RWTPCValBufferBaseGuarded classes to select the next enqueued runnable 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: bool 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, bool, &YourClass::yourFunc); runnableServer.enqueue(doSomething, guard2); runnableServer.stop(); runnableServer.join(); return 0; }
typedef RWTFunctorR0<bool>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 a bool. |
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 a bool. |
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 a bool. |
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).
RWRunnableServer, RWServerPool
© 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.