8#include <daq/rfarm/event/hltsocket/HLTMainLoop.h>
10#include <framework/logging/Logger.h>
16using namespace std::chrono_literals;
19bool HLTMainLoop::s_interrupted =
false;
21void HLTMainLoop::signalHandler(
int )
23 B2RESULT(
"Termination request...");
24 HLTMainLoop::s_interrupted =
true;
27HLTMainLoop::HLTMainLoop()
32bool HLTMainLoop::isRunning()
const
34 return not s_interrupted;
37void HLTMainLoop::initSignalHandler()
const
39 struct sigaction action;
40 action.sa_handler = signalHandler;
42 sigemptyset(&action.sa_mask);
43 sigaction(SIGINT, &action, NULL);
44 sigaction(SIGTERM, &action, NULL);
47int HLTMainLoop::writeToRingBufferWaiting(
RingBuffer* ringBuffer,
int* buffer,
unsigned int size)
const
51 irb = ringBuffer->
insq(buffer, size);
55 std::this_thread::sleep_for(20us);
61int HLTMainLoop::readFromRingBufferWaiting(
RingBuffer* ringBuffer,
int* buffer)
const
64 while ((bsize = ringBuffer->
remq(buffer)) == 0 and isRunning()) {
65 std::this_thread::sleep_for(20us);
Class to manage a Ring Buffer placed in an IPC shared memory.
int insq(const int *buf, int size, bool checkTx=false)
Append a buffer to the RingBuffer.
int remq(int *buf)
Pick up a buffer from the RingBuffer.
Abstract base class for different kinds of events.