Belle II Software development
Rb2Sock Class Reference

Public Member Functions

 Rb2Sock (std::string rbuf, std::string dest, int port)
 Constuctor and Destructor.
 
int SendEvent (void)
 Event function.
 

Private Attributes

RingBufferm_rbuf
 
EvtSocketSendm_sock
 
char * m_evtbuf
 

Detailed Description

Definition at line 23 of file Rb2Sock.h.

Constructor & Destructor Documentation

◆ Rb2Sock()

Rb2Sock ( std::string  rbuf,
std::string  dest,
int  port 
)

Constuctor and Destructor.

Definition at line 16 of file Rb2Sock.cc.

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

◆ ~Rb2Sock()

~Rb2Sock ( void  )

Definition at line 25 of file Rb2Sock.cc.

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

Member Function Documentation

◆ SendEvent()

int SendEvent ( void  )

Event function.

Definition at line 31 of file Rb2Sock.cc.

32{
33 // Get a record from ringbuf
34 int size;
35 while ((size = m_rbuf->remq((int*)m_evtbuf)) == 0) {
36 // printf ( "Rx : evtbuf is not available yet....\n" );
37 // usleep(100);
38 usleep(20);
39 }
40
41 EvtMessage* msg = new EvtMessage(m_evtbuf); // Ptr copy, no overhead
42
43 if (msg->type() == MSG_TERMINATE) {
44 printf("EoF found. Exitting.....\n");
45 m_sock->send(msg);
46 delete msg;
47 return -1;
48 } else {
49 int is = m_sock->send(msg);
50 delete msg;
51 return is;
52 // return msg->size();
53 }
54}
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 35 of file Rb2Sock.h.

◆ m_rbuf

RingBuffer* m_rbuf
private

Definition at line 33 of file Rb2Sock.h.

◆ m_sock

EvtSocketSend* m_sock
private

Definition at line 34 of file Rb2Sock.h.


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