#include <ulxr_mtrpc_server.h>
Inheritance diagram for ulxr::MultiThreadRpcServer:


Public Types | |
| typedef void *(*) | ThreadLoopFunction (ThreadData *) |
Public Member Functions | |
| MultiThreadRpcServer (Protocol *prot, unsigned num, bool wbxml_mode=false) | |
| Constructs the rpc server. | |
| virtual | ~MultiThreadRpcServer () |
| Destrcuts the rpc server. | |
| unsigned | dispatchAsync () |
| Lauch the rpc server threads which wait for requests. | |
| unsigned | numThreads () const |
| Gets the number of installed threads. | |
| void | terminateAllThreads (unsigned time=0) |
| Terminates all threads. | |
| void | shutdownAllThreads (unsigned time=0) |
| Signals termination and shuts down all ports. | |
| void | waitAsync (bool term, bool stat=false) |
| Waits for all threads to complete. | |
| void | addMethod (MethodAdder::StaticMethodCall_t adr, const CppString &ret_signature, const CppString &name, const CppString &signature, const CppString &help) |
| Adds a user defined (static) method to the dispatcher. | |
| void | addMethod (MethodAdder::DynamicMethodCall_t wrapper, const CppString &ret_signature, const CppString &name, const CppString &signature, const CppString &help) |
| Adds a user defined (dynamic) method to the dispatcher. | |
| void | addMethod (MethodAdder::SystemMethodCall_t adr, const CppString &ret_signature, const CppString &name, const CppString &signature, const CppString &help) |
| Adds a system internal method to the dispatcher. | |
| void | addMethod (MethodAdder::StaticMethodCall_t adr, const Signature &ret_signature, const CppString &name, const Signature &signature, const CppString &help) |
| Adds a user defined (static) method to the dispatcher. | |
| void | addMethod (MethodAdder::DynamicMethodCall_t wrapper, const Signature &ret_signature, const CppString &name, const Signature &signature, const CppString &help) |
| Adds a user defined (dynamic) method to the dispatcher. | |
| void | addMethod (MethodAdder::SystemMethodCall_t adr, const Signature &ret_signature, const CppString &name, const Signature &signature, const CppString &help) |
| Adds a system internal method to the dispatcher. | |
| void | removeMethod (const CppString &name) |
| Removes a method if available. | |
Protected Member Functions | |
| virtual void | forwardThreadedError (const Exception &ex) const |
| Forwards error that happen within threads. | |
| void * | serverLoop (Protocol *protocol, ThreadData *td) |
| void | printStatistics () const |
| Prints some statistics about the running threads. | |
| virtual void | preProcessCall (MethodCall &call) |
| Processes a call after it has been recieved and before it is dispatched. | |
| virtual void | preProcessResponse (MethodResponse &resp) |
| Processes a method response before it is sent back. | |
Private Types | |
| typedef void *( | Thread_t )(ThreadData *) |
Private Member Functions | |
| void | releaseThreads () |
| Deletes all allocated thread objects. | |
| MultiThreadRpcServer (const MultiThreadRpcServer &) | |
| MultiThreadRpcServer & | operator= (const MultiThreadRpcServer &) |
Static Private Member Functions | |
| static void * | startThread (ThreadData *td) |
| Helper method to start a thread. | |
Private Attributes | |
| std::vector< ThreadData * > | threads |
| Dispatcher | dispatcher |
| bool | wbxml_mode |
Classes | |
| class | ThreadData |
Definition at line 61 of file ulxr_mtrpc_server.h.
| typedef void*(*) ulxr::MultiThreadRpcServer::ThreadLoopFunction(ThreadData *) |
Definition at line 66 of file ulxr_mtrpc_server.h.
typedef void*( ulxr::MultiThreadRpcServer::Thread_t)(ThreadData *) [private] |
Definition at line 254 of file ulxr_mtrpc_server.h.
| ulxr::MultiThreadRpcServer::MultiThreadRpcServer | ( | Protocol * | prot, | |
| unsigned | num, | |||
| bool | wbxml_mode = false | |||
| ) |
Constructs the rpc server.
| prot | communication object | |
| num | number of simultanous threads to handle requests | |
| wbxml_mode | true: data is sent as wbxml |
Definition at line 132 of file ulxr_mtrpc_server.cpp.
References ulxr::Protocol::detach(), threads, and wbxml_mode.
| ulxr::MultiThreadRpcServer::~MultiThreadRpcServer | ( | ) | [virtual] |
Destrcuts the rpc server.
Definition at line 144 of file ulxr_mtrpc_server.cpp.
References releaseThreads(), and waitAsync().
| ulxr::MultiThreadRpcServer::MultiThreadRpcServer | ( | const MultiThreadRpcServer & | ) | [private] |
| unsigned ulxr::MultiThreadRpcServer::dispatchAsync | ( | ) |
Lauch the rpc server threads which wait for requests.
Definition at line 377 of file ulxr_mtrpc_server.cpp.
References ULXR_PCHAR, and ULXR_TRACE.
| unsigned ulxr::MultiThreadRpcServer::numThreads | ( | ) | const |
Gets the number of installed threads.
Definition at line 409 of file ulxr_mtrpc_server.cpp.
| void ulxr::MultiThreadRpcServer::terminateAllThreads | ( | unsigned | time = 0 |
) |
Terminates all threads.
The threads only get a message and must terminate themselves.
| time | planned: time in ms to wait before killing. |
Definition at line 415 of file ulxr_mtrpc_server.cpp.
References ULXR_PCHAR, and ULXR_TRACE.
| void ulxr::MultiThreadRpcServer::shutdownAllThreads | ( | unsigned | time = 0 |
) |
Signals termination and shuts down all ports.
This is a rather rude way to terminate to stop the servers
| time | planned: time in ms to wait before killing. |
Definition at line 423 of file ulxr_mtrpc_server.cpp.
References ULXR_PCHAR, and ULXR_TRACE.
| void ulxr::MultiThreadRpcServer::waitAsync | ( | bool | term, | |
| bool | stat = false | |||
| ) |
Waits for all threads to complete.
| term | true: signal all threads to shut down as soon as possible. | |
| stat | true: print some statistical data to stdout. |
Definition at line 444 of file ulxr_mtrpc_server.cpp.
References ULXR_PCHAR, and ULXR_TRACE.
Referenced by ~MultiThreadRpcServer().
| void ulxr::MultiThreadRpcServer::addMethod | ( | MethodAdder::StaticMethodCall_t | adr, | |
| const CppString & | ret_signature, | |||
| const CppString & | name, | |||
| const CppString & | signature, | |||
| const CppString & | help | |||
| ) | [virtual] |
Adds a user defined (static) method to the dispatcher.
You access a remote method by sending the "official" name. Sometimes a method accepts different parameter sets (overloading in C++). In this case you add the according signature. Finally you can add a description to show the usage of this method.
| adr | the pointer to the implementation of the method | |
| ret_signature | the signature of the return value | |
| name | the name of the method | |
| signature | the signature of the parameters | |
| help | short usage description |
Implements ulxr::MethodAdder.
Definition at line 153 of file ulxr_mtrpc_server.cpp.
| void ulxr::MultiThreadRpcServer::addMethod | ( | MethodAdder::DynamicMethodCall_t | wrapper, | |
| const CppString & | ret_signature, | |||
| const CppString & | name, | |||
| const CppString & | signature, | |||
| const CppString & | help | |||
| ) | [virtual] |
Adds a user defined (dynamic) method to the dispatcher.
You access a remote method by sending the "official" name. Sometimes a method accepts different parameter sets (overloading in C++). In this case you add the according signature. Finally you can add a description to show the usage of this method.
| wrapper | the pointer to the wrapper to the method. Important: Dispatcher owns now and deletes this wrapper object! | |
| ret_signature | the signature of the return value | |
| name | the name of the method | |
| signature | the signature of the parameters | |
| help | short usage description |
Implements ulxr::MethodAdder.
Definition at line 164 of file ulxr_mtrpc_server.cpp.
| void ulxr::MultiThreadRpcServer::addMethod | ( | MethodAdder::SystemMethodCall_t | adr, | |
| const CppString & | ret_signature, | |||
| const CppString & | name, | |||
| const CppString & | signature, | |||
| const CppString & | help | |||
| ) | [virtual] |
Adds a system internal method to the dispatcher.
You access a remote method by sending the "official" name. Sometimes a method accepts different parameter sets (overloading in C++). In this case you add the according signature. Finally you can add a description to show the usage of this method.
| adr | the pointer to the implementation of the method | |
| ret_signature | the signature of the return value | |
| name | the name of the method | |
| signature | the signature of the parameters | |
| help | short usage description |
Implements ulxr::MethodAdder.
| void ulxr::MultiThreadRpcServer::addMethod | ( | MethodAdder::StaticMethodCall_t | adr, | |
| const Signature & | ret_signature, | |||
| const CppString & | name, | |||
| const Signature & | signature, | |||
| const CppString & | help | |||
| ) | [virtual] |
Adds a user defined (static) method to the dispatcher.
You access a remote method by sending the "official" name. Sometimes a method accepts different parameter sets (overloading in C++). In this case you add the according signature. Finally you can add a description to show the usage of this method.
| adr | the pointer to the implementation of the method | |
| ret_signature | the signature of the return value | |
| name | the name of the method | |
| signature | the signature of the parameters | |
| help | short usage description |
Implements ulxr::MethodAdder.
Definition at line 186 of file ulxr_mtrpc_server.cpp.
| void ulxr::MultiThreadRpcServer::addMethod | ( | MethodAdder::DynamicMethodCall_t | wrapper, | |
| const Signature & | ret_signature, | |||
| const CppString & | name, | |||
| const Signature & | signature, | |||
| const CppString & | help | |||
| ) | [virtual] |
Adds a user defined (dynamic) method to the dispatcher.
You access a remote method by sending the "official" name. Sometimes a method accepts different parameter sets (overloading in C++). In this case you add the according signature. Finally you can add a description to show the usage of this method.
| wrapper | the pointer to the wrapper to the method. Important: Dispatcher owns now and deletes this wrapper object! | |
| ret_signature | the signature of the return value | |
| name | the name of the method | |
| signature | the signature of the parameters | |
| help | short usage description |
Implements ulxr::MethodAdder.
Definition at line 197 of file ulxr_mtrpc_server.cpp.
| void ulxr::MultiThreadRpcServer::addMethod | ( | MethodAdder::SystemMethodCall_t | adr, | |
| const Signature & | ret_signature, | |||
| const CppString & | name, | |||
| const Signature & | signature, | |||
| const CppString & | help | |||
| ) | [virtual] |
Adds a system internal method to the dispatcher.
You access a remote method by sending the "official" name. Sometimes a method accepts different parameter sets (overloading in C++). In this case you add the according signature. Finally you can add a description to show the usage of this method.
| adr | the pointer to the implementation of the method | |
| ret_signature | the signature of the return value | |
| name | the name of the method | |
| signature | the signature of the parameters | |
| help | short usage description |
Implements ulxr::MethodAdder.
| void ulxr::MultiThreadRpcServer::removeMethod | ( | const CppString & | name | ) | [virtual] |
Removes a method if available.
| name | method name |
Implements ulxr::MethodAdder.
Definition at line 219 of file ulxr_mtrpc_server.cpp.
| void ulxr::MultiThreadRpcServer::forwardThreadedError | ( | const Exception & | ex | ) | const [protected, virtual] |
Forwards error that happen within threads.
| ex | Exception that occured |
Definition at line 361 of file ulxr_mtrpc_server.cpp.
References ULXR_CHAR, and ULXR_TRACE.
| void * ulxr::MultiThreadRpcServer::serverLoop | ( | Protocol * | protocol, | |
| ThreadData * | td | |||
| ) | [protected] |
Definition at line 235 of file ulxr_mtrpc_server.cpp.
References ulxr::ApplicationError, ulxr::SystemError, ULXR_GET_STRING, ULXR_PCHAR, ULXR_TRACE, ulxr::Dispatcher::waitForCall(), and ulxr::Exception::why().
| void ulxr::MultiThreadRpcServer::printStatistics | ( | ) | const [protected] |
Prints some statistics about the running threads.
Definition at line 489 of file ulxr_mtrpc_server.cpp.
References ULXR_COUT, and ULXR_PCHAR.
| void ulxr::MultiThreadRpcServer::preProcessCall | ( | MethodCall & | call | ) | [protected, virtual] |
Processes a call after it has been recieved and before it is dispatched.
| call | last received call |
Definition at line 225 of file ulxr_mtrpc_server.cpp.
| void ulxr::MultiThreadRpcServer::preProcessResponse | ( | MethodResponse & | resp | ) | [protected, virtual] |
Processes a method response before it is sent back.
| resp | response to send back |
Definition at line 230 of file ulxr_mtrpc_server.cpp.
| void * ulxr::MultiThreadRpcServer::startThread | ( | ThreadData * | td | ) | [static, private] |
Helper method to start a thread.
| td | pointer to thread data |
Definition at line 368 of file ulxr_mtrpc_server.cpp.
References ULXR_PCHAR, and ULXR_TRACE.
| void ulxr::MultiThreadRpcServer::releaseThreads | ( | ) | [private] |
Deletes all allocated thread objects.
Definition at line 476 of file ulxr_mtrpc_server.cpp.
References ULXR_PCHAR, and ULXR_TRACE.
Referenced by ~MultiThreadRpcServer().
| MultiThreadRpcServer& ulxr::MultiThreadRpcServer::operator= | ( | const MultiThreadRpcServer & | ) | [private] |
std::vector<ThreadData*> ulxr::MultiThreadRpcServer::threads [private] |
Definition at line 257 of file ulxr_mtrpc_server.h.
bool ulxr::MultiThreadRpcServer::wbxml_mode [private] |
1.5.1