REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
Data Structures | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Attributes
TRestMessenger Class Reference

Detailed Description

TRestMessenger

This metadata helps to recieve/dispatch messages across processes(UNIX process) For example, we start two restManager with TRestMessenger added as metadata. For one of them, we add a "sendMessage" task after "processEvent". Then, when the process chain finishes, it will dispatch the message containing, e.g., the output file name. Then, the other restManager can get the message and be notified that the file is done. It can therefore do some operations to this file, e.g., add to TRestAnalysisPlot file list and update the plots.

By default it uses shared memory. Can be overridden by REST packages, adding more communication methods(http, kafka, etc.)

Each TRestMessenger connects to a message pool in shared memory. Each message pool is limited with 100 messages. Each message is limited with 256 bytes. When sending message, the message is added to the message pool. When receiving message, the logic is more like "consuming": message is taken out from the pool and given to the specific process. It will be erased after being consumed. TRestMessenger cannot consume the message sent by self process.

The rml definition is like follows. We need to add serval <pool sections in its config section to define the message pools. The token of the pool is equivalent to the shm key, where two processes with a same token can access to a same memory.

<TRestManager name="CoBoDataAnalysis" title="Example" verboseLevel="info" >
<TRestMessenger name="Messager" title="Example" verboseLevel="info"
messageSource="outputfile" token="116027"/>
<addTask command="Messager->SendMessage()" value="ON"/>
Managing applications and executing tasks.
Definition: TRestManager.h:16

RESTsoft - Software for Rare Event Searches with TPCs

History of developments:

2020-Aug: First implementation and concept Ni Kaixiang

Author
Ni Kaixiang

Definition at line 29 of file TRestMessenger.h.

Inheritance diagram for TRestMessenger:
TRestMetadata

Data Structures

struct  messagepool_t
 

Public Member Functions

 ClassDefOverride (TRestMessenger, 1)
 
virtual std::string ConsumeMessage ()
 
virtual bool IsConnected ()
 
void PrintMetadata () override
 Implemented it in the derived metadata class to print out specific metadata information. More...
 
virtual void SendMessage (std::string message="")
 
virtual std::vector< std::string > ShowMessagePool ()
 
 TRestMessenger (int token, std::string mode="TwoWay")
 

Protected Types

enum  CommMode { MessagePool_Host , MessagePool_Client , MessagePool_TwoWay }
 

Protected Member Functions

virtual void AddPool (std::string message)
 
virtual void InitFromConfigFile () override
 To make settings from rml file. This method must be implemented in the derived class.
 
virtual void Initialize () override
 Making default settings.
 
bool lock (messagepool_t *pool, int timeoutMs=1000)
 
bool unlock (messagepool_t *pool, int timeoutMs=1000)
 

Protected Attributes

CommMode fMode
 
std::string fPoolSource
 
std::string fPoolToken
 
TRestRunfRun
 

Private Attributes

messagepool_tfMessagePool
 
int fShmId
 

Member Function Documentation

◆ PrintMetadata()

void TRestMessenger::PrintMetadata ( )
overridevirtual

Implemented it in the derived metadata class to print out specific metadata information.

Prints metadata content on screen. Usually overloaded by the derived metadata class.

Reimplemented from TRestMetadata.

Definition at line 351 of file TRestMessenger.cxx.


The documentation for this class was generated from the following files: