Belle II Software development
HLTMainLoop Class Reference

Public Member Functions

bool isRunning () const
 
int writeToRingBufferWaiting (RingBuffer *ringBuffer, int *buffer, unsigned int size) const
 
int readFromRingBufferWaiting (RingBuffer *ringBuffer, int *buffer) const
 

Private Member Functions

void initSignalHandler () const
 

Static Private Member Functions

static void signalHandler (int signalValue)
 

Static Private Attributes

static bool s_interrupted = false
 

Detailed Description

Definition at line 18 of file HLTMainLoop.h.

Constructor & Destructor Documentation

◆ HLTMainLoop()

Definition at line 27 of file HLTMainLoop.cc.

28{
29 initSignalHandler();
30}

Member Function Documentation

◆ initSignalHandler()

void initSignalHandler ( ) const
private

Definition at line 37 of file HLTMainLoop.cc.

38{
39 struct sigaction action;
40 action.sa_handler = signalHandler;
41 action.sa_flags = 0;
42 sigemptyset(&action.sa_mask);
43 sigaction(SIGINT, &action, NULL);
44 sigaction(SIGTERM, &action, NULL);
45}

◆ isRunning()

bool isRunning ( ) const

Definition at line 32 of file HLTMainLoop.cc.

33{
34 return not s_interrupted;
35}

◆ readFromRingBufferWaiting()

int readFromRingBufferWaiting ( RingBuffer ringBuffer,
int *  buffer 
) const

Definition at line 61 of file HLTMainLoop.cc.

62{
63 int bsize = 0;
64 while ((bsize = ringBuffer->remq(buffer)) == 0 and isRunning()) {
65 std::this_thread::sleep_for(20us);
66 }
67
68 return bsize;
69}
int remq(int *buf)
Pick up a buffer from the RingBuffer.
Definition: RingBuffer.cc:308

◆ signalHandler()

void signalHandler ( int  signalValue)
staticprivate

Definition at line 21 of file HLTMainLoop.cc.

22{
23 B2RESULT("Termination request...");
24 HLTMainLoop::s_interrupted = true;
25}

◆ writeToRingBufferWaiting()

int writeToRingBufferWaiting ( RingBuffer ringBuffer,
int *  buffer,
unsigned int  size 
) const

Definition at line 47 of file HLTMainLoop.cc.

48{
49 int irb = 0;
50 while (isRunning()) {
51 irb = ringBuffer->insq(buffer, size);
52 if (irb >= 0) {
53 break;
54 }
55 std::this_thread::sleep_for(20us);
56 }
57
58 return irb;
59}
int insq(const int *buf, int size, bool checkTx=false)
Append a buffer to the RingBuffer.
Definition: RingBuffer.cc:189

Member Data Documentation

◆ s_interrupted

bool s_interrupted = false
staticprivate

Definition at line 27 of file HLTMainLoop.h.


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