9 #include <daq/rfarm/event/modules/FastRbuf2DsModule.h>
21 void* RunRbufReader(
void*)
39 setDescription(
"Encode DataStore into RingBuffer");
42 addParam(
"RingBufferName", m_rbufname,
"Name of RingBuffer",
44 addParam(
"CompressionLevel", m_compressionLevel,
"Compression level",
46 addParam(
"NumThreads", m_numThread,
"Number of threads for object decoding",
56 B2INFO(
"Rx: Constructor done.");
60 FastRbuf2DsModule::~FastRbuf2DsModule()
64 void FastRbuf2DsModule::initialize()
66 gSystem->Load(
"libdataobjects");
82 char* evtbuf =
new char[MAXEVTSIZE];
83 while ((size = m_rbuf->remq((
int*)evtbuf)) == 0) usleep(20);
88 m_streamer->restoreDataStore(evtmsg);
90 B2FATAL(
"SeqRootInput : Error in reading first event");
96 pthread_attr_t thread_attr;
97 pthread_attr_init(&thread_attr);
101 pthread_create(&m_thr_input, NULL, RunRbufReader, NULL);
120 B2INFO(
"Rx initialized.");
123 void FastRbuf2DsModule::ReadRbufInThread()
125 printf(
"ReadFileInThread started!!\n");
128 char* evtbuf =
new char[EvtMessage::c_MaxEventSize];
130 while ((size = m_rbuf->remq((
int*)evtbuf)) == 0) usleep(20);
132 printf(
"ReadRbufInThread : ERROR! record with size=0 detected!!!!!\n");
133 m_streamer->queueEvtMessage(NULL);
136 }
else if (size > 0) {
137 m_streamer->queueEvtMessage(evtbuf);
139 B2FATAL(
"FastRbuf2Ds : Error in reading first event");
147 void FastRbuf2DsModule::beginRun()
149 B2INFO(
"beginRun called.");
153 void FastRbuf2DsModule::event()
157 if (m_nrecv == 0)
return;
160 m_streamer->restoreDataStoreAsync();
162 B2INFO(
"FastRbuf2Ds: DataStore Restored!!");
167 void FastRbuf2DsModule::endRun()
171 B2INFO(
"FastRbuf2Ds: endRun done.");
175 void FastRbuf2DsModule::terminate()
177 pthread_join(m_thr_input, NULL);
178 B2INFO(
"FastRbuf2Ds: terminate called");
Stream/restore DataStore objects to/from EvtMessage.
Class to manage streamed object.
A class definition of an input module for Sequential ROOT I/O.
void ReadRbufInThread()
Function to read event from RB.
Class to manage a Ring Buffer placed in an IPC shared memory.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.