Belle II Software  release-05-02-19
AsyncWrapper.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2013 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Christian Pulvermacher *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 
13 #include <framework/core/Module.h>
14 
15 namespace Belle2 {
20  class RxModule;
21  class TxModule;
22  class RingBuffer;
23 
36  class AsyncWrapper : public Module {
37  public:
41  explicit AsyncWrapper(const std::string& moduleType);
42 
43  ~AsyncWrapper();
44 
47 
52  void initialize() override;
54  void event() override;
56  void terminate() override;
57 
59  static bool isAsync() { return s_isAsync; }
60 
62  static int numAvailableEvents();
63 
64 
65  private:
68 
71 
73  RxModule* m_rx;
74 
76  TxModule* m_tx;
77 
79  bool m_discardOldEvents;
80 
82  static bool s_isAsync;
83 
86  };
88 }
Belle2::AsyncWrapper::numAvailableEvents
static int numAvailableEvents()
Retun number of events available in the RingBuffer.
Definition: AsyncWrapper.cc:43
Belle2::AsyncWrapper::s_currentRingBuffer
static RingBuffer * s_currentRingBuffer
if s_isAsync is true, this contains the corresponding RingBuffer, see numAvailableEvents().
Definition: AsyncWrapper.h:93
Belle2::AsyncWrapper::s_isAsync
static bool s_isAsync
true if the current process is on the receiving (async) side of an AsyncWrapper.
Definition: AsyncWrapper.h:90
Belle2::RxModule
Module to decode data store contents from RingBuffer.
Definition: RxModule.h:25
Belle2::TxModule
Module for encoding data store contents into a RingBuffer.
Definition: TxModule.h:25
Belle2::AsyncWrapper::terminate
void terminate() override
Call this from terminate().
Definition: AsyncWrapper.cc:117
Belle2::AsyncWrapper::getWrapped
ModulePtr getWrapped()
Access wrapped module (owned by AsyncWrapper).
Definition: AsyncWrapper.h:54
Belle2::AsyncWrapper::m_tx
TxModule * m_tx
transmitting module.
Definition: AsyncWrapper.h:84
Belle2::RingBuffer
Class to manage a Ring Buffer placed in an IPC shared memory.
Definition: RingBuffer.h:36
Belle2::AsyncWrapper::isAsync
static bool isAsync()
returns true if the current process is on the receiving (async) side of an AsyncWrapper.
Definition: AsyncWrapper.h:67
Belle2::AsyncWrapper::event
void event() override
Call this from event().
Definition: AsyncWrapper.cc:105
Belle2::AsyncWrapper::m_discardOldEvents
bool m_discardOldEvents
Discard old events when buffer is full.
Definition: AsyncWrapper.h:87
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::ModulePtr
std::shared_ptr< Module > ModulePtr
Defines a pointer to a module object as a boost shared pointer.
Definition: Module.h:42
Belle2::AsyncWrapper::m_rx
RxModule * m_rx
receiving module.
Definition: AsyncWrapper.h:81
Belle2::AsyncWrapper::initialize
void initialize() override
Call this from initialize().
Definition: AsyncWrapper.cc:66
Belle2::AsyncWrapper::AsyncWrapper
AsyncWrapper(const std::string &moduleType)
Wrap am module of given type.
Definition: AsyncWrapper.cc:53
Belle2::AsyncWrapper::m_wrappedModule
ModulePtr m_wrappedModule
The wrapped module.
Definition: AsyncWrapper.h:75
Belle2::AsyncWrapper::m_ringBuffer
RingBuffer * m_ringBuffer
shared memory buffer
Definition: AsyncWrapper.h:78