Send Pattern

Figure: Send Pattern

  • The sixth example demonstrates the usage of a send server and a send client ports.
  • The send pattern implements a client initiated one-way communication. It transmits a communication object from a client (service requestor) to the server (service provider). It is used, for example, to control the velocity or the steering angle of a mobile platform. It can also be used to implement a data driven processing chain of components.
  • The server can handle an arbitrary number of connected clients (see figure below).
  • It provides a member function based interface at the service requestor and a handler based interface at the service provider.
  • The service requestor can send communication objects to the service provider using the send member function. At the service provider, each incoming communication object is forwarded to the registered handler for further processing.
  • The handler at the service provider has to be derived from the abstract handler class to provide an implementation of the handleSend member function which processes the incoming commands.
  • Due to the handler based approach, no incoming communication object is lost. All the communication objects of all connected clients are handled in an arbitrary order. However, all communication objects of a single client are handled in the order of being sent.
  • In case of a passive handler, the processing of incoming commands is driven by the upcalling thread of the send server. Thus, the execution of the next incoming communication object is blocked until the passive handler returns. A passive handler makes sense if only short and non-blocking activities are involved. It avoids the overhead of thread generation inside the send server.
  • Any kind of active handler can be used to decouple the processing of incoming communication objects from the send server. The advantage of a user side threading model is that one is free to implement any kind of needed threading model (thread per incoming communication object, thread pool etc.). The passive handler just hands over the incoming communication object but does not process it. Since there is no separate thread created inside the server to handle the upcall, there is no waste of resources in case of using an active handler (it makes no sense to have a separate thread per upcall in case of an active handler).
  • An already implemented example of an active handler is given by the Queue Send Server Handler. All incoming communication objects are stored in a queue and another thread is handling one communication object after the next (independently of the upcall of the send server).

Figure: Several send clients