JANA2
C++ framework for multi-threaded data processing
JTransport Struct Referenceabstract

JTransport is a lightweight wrapper for integrating different messaging systems with JANA. More...

#include <JTransport.h>

Public Types

enum  Result {
  SUCCESS ,
  FAILURE ,
  TRY_AGAIN ,
  FINISHED
}
 

Public Member Functions

virtual void initialize ()=0
 Called exactly once before any calls to send or receive. More...
 
virtual Result send (const JMessage &src_msg)=0
 send should block until the underlying transport has successfully enqueued the message somewhere else. More...
 
virtual Result receive (JMessage &dest_msg)=0
 receive should return as soon as the dest_msg has been written. More...
 
virtual ~JTransport ()=default
 It is reasonable to close sockets in the destructor, since: a. More...
 

Detailed Description

JTransport is a lightweight wrapper for integrating different messaging systems with JANA.

Member Enumeration Documentation

◆ Result

Enumerator
SUCCESS 

send/recv succeeded

FAILURE 

Not sure if we want this. Probably throw an exception instead.

TRY_AGAIN 

send/recv failed

FINISHED 

Not sure if we want this. End-of-stream happens at a higher level.

Constructor & Destructor Documentation

◆ ~JTransport()

virtual JTransport::~JTransport ( )
virtualdefault

It is reasonable to close sockets in the destructor, since: a.

The JTransport doesn't have an end-of-stream concept to hook a close() method to b. The JStreamingEventSource owns the JTransport, so it can destroy it as soon as it is done with it

Member Function Documentation

◆ initialize()

virtual void JTransport::initialize ( )
pure virtual

Called exactly once before any calls to send or receive.

Use for opening sockets, etc. We don't open sockets in the constructor because JANA expects multiple event sources, which might be constructed immediately but not used until much later, unnecessarily tying up resources.

◆ receive()

virtual Result JTransport::receive ( JMessage dest_msg)
pure virtual

receive should return as soon as the dest_msg has been written.

If there are no messages waiting, receive should return TRY_AGAIN immediately instead of blocking.

◆ send()

virtual Result JTransport::send ( const JMessage src_msg)
pure virtual

send should block until the underlying transport has successfully enqueued the message somewhere else.

This allows the caller to reuse the same JMessage buffer immediately.


The documentation for this struct was generated from the following file: