Belle II Software development
RevRb2Sock Class Reference

Public Member Functions

 RevRb2Sock (std::string rbuf, int port, std::string shmname, int id)
 Constuctor and Destructor.
 
int SendEvent (void)
 Event function.
 

Private Attributes

RingBufferm_rbuf
 
REvtSocketSendm_sock
 
RFFlowStatm_flow
 
char * m_evtbuf
 

Detailed Description

Definition at line 24 of file RevRb2Sock.h.

Constructor & Destructor Documentation

◆ RevRb2Sock()

RevRb2Sock ( std::string  rbuf,
int  port,
std::string  shmname,
int  id 
)

Constuctor and Destructor.

Definition at line 16 of file RevRb2Sock.cc.

17{
18 // m_rbuf = new RingBuffer((char*)rbuf.c_str(), RBUFSIZE);
19 m_rbuf = new RingBuffer((char*)rbuf.c_str());
20 m_sock = new REvtSocketSend(port);
21 m_evtbuf = new char[MAXEVTSIZE];
22 m_flow = new RFFlowStat((char*)shmname.c_str(), id, m_rbuf);
23
24}
Class to manage a Ring Buffer placed in an IPC shared memory.
Definition: RingBuffer.h:39

◆ ~RevRb2Sock()

~RevRb2Sock ( void  )

Definition at line 26 of file RevRb2Sock.cc.

27{
28 delete m_sock;
29 delete m_rbuf;
30}

Member Function Documentation

◆ SendEvent()

int SendEvent ( void  )

Event function.

Definition at line 32 of file RevRb2Sock.cc.

33{
34 // Get a record from ringbuf
35 int size;
36 while ((size = m_rbuf->remq((int*)m_evtbuf)) == 0) {
37 // printf ( "Rx : evtbuf is not available yet....\n" );
38 // usleep(100);
39 usleep(20);
40 }
41 m_flow->log(size * 4);
42
43 EvtMessage* msg = new EvtMessage(m_evtbuf); // Ptr copy, no overhead
44
45 if (msg->type() == MSG_TERMINATE) {
46 printf("EoF found. Exitting.....\n");
47 m_sock->send(msg);
48 delete msg;
49 return -1;
50 } else {
51 int is = m_sock->send(msg);
52 delete msg;
53 return is;
54 // return msg->size();
55 }
56}
Class to manage streamed object.
Definition: EvtMessage.h:59
ERecordType type() const
Get record type.
Definition: EvtMessage.cc:114
int remq(int *buf)
Pick up a buffer from the RingBuffer.
Definition: RingBuffer.cc:308

Member Data Documentation

◆ m_evtbuf

char* m_evtbuf
private

Definition at line 37 of file RevRb2Sock.h.

◆ m_flow

RFFlowStat* m_flow
private

Definition at line 36 of file RevRb2Sock.h.

◆ m_rbuf

RingBuffer* m_rbuf
private

Definition at line 34 of file RevRb2Sock.h.

◆ m_sock

REvtSocketSend* m_sock
private

Definition at line 35 of file RevRb2Sock.h.


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