Belle II Software development
AsyncWrapper.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#pragma once
10
11#include <framework/core/Module.h>
12
13namespace Belle2 {
18 class RxModule;
19 class TxModule;
20 class RingBuffer;
21
34 class AsyncWrapper : public Module {
35 public:
39 explicit AsyncWrapper(const std::string& moduleType);
40
42
45
50 void initialize() override;
52 void event() override;
54 void terminate() override;
55
57 static bool isAsync() { return s_isAsync; }
58
60 static int numAvailableEvents();
61
62
63 private:
66
69
72
75
78
80 static bool s_isAsync;
81
84 };
86}
Wraps a given Module to execute it asynchronously.
Definition: AsyncWrapper.h:34
ModulePtr getWrapped()
Access wrapped module (owned by AsyncWrapper).
Definition: AsyncWrapper.h:44
TxModule * m_tx
transmitting module.
Definition: AsyncWrapper.h:74
void initialize() override
Call this from initialize().
Definition: AsyncWrapper.cc:64
void event() override
Call this from event().
void terminate() override
Call this from terminate().
ModulePtr m_wrappedModule
The wrapped module.
Definition: AsyncWrapper.h:65
static bool isAsync()
returns true if the current process is on the receiving (async) side of an AsyncWrapper.
Definition: AsyncWrapper.h:57
RxModule * m_rx
receiving module.
Definition: AsyncWrapper.h:71
static int numAvailableEvents()
Retun number of events available in the RingBuffer.
Definition: AsyncWrapper.cc:41
RingBuffer * m_ringBuffer
shared memory buffer
Definition: AsyncWrapper.h:68
static RingBuffer * s_currentRingBuffer
if s_isAsync is true, this contains the corresponding RingBuffer, see numAvailableEvents().
Definition: AsyncWrapper.h:83
static bool s_isAsync
true if the current process is on the receiving (async) side of an AsyncWrapper.
Definition: AsyncWrapper.h:80
bool m_discardOldEvents
Discard old events when buffer is full.
Definition: AsyncWrapper.h:77
Base class for Modules.
Definition: Module.h:72
Class to manage a Ring Buffer placed in an IPC shared memory.
Definition: RingBuffer.h:39
Module to decode data store contents from RingBuffer.
Definition: RxModule.h:25
Module for encoding data store contents into a RingBuffer.
Definition: TxModule.h:25
std::shared_ptr< Module > ModulePtr
Defines a pointer to a module object as a boost shared pointer.
Definition: Module.h:43
Abstract base class for different kinds of events.