ATLAS Offline Software
SGHiveMgrSvc.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef STOREGATE_HIVEMGRSVC_H
6 #define STOREGATE_HIVEMGRSVC_H
7 
8 #include <vector>
9 #include <string>
10 #include <mutex>
11 
12 #include "GaudiKernel/Service.h"
13 #include "GaudiKernel/ServiceHandle.h"
14 #include "GaudiKernel/StatusCode.h"
15 #include "GaudiKernel/IHiveWhiteBoard.h"
16 
17 #include "StoreGate/StoreGateSvc.h"
19 
20 class StoreGateSvc;
21 class ISvcLocator;
22 class HltEventLoopMgr; // friend
23 
29 namespace SG {
30 class HiveMgrSvc : public extends<Service, IHiveWhiteBoard> {
31  friend class TestSGHiveMgrSvc;
32  friend class ::HltEventLoopMgr;
33 public:
35 
41  virtual StatusCode selectStore(size_t slotIndex) override;
42 
48  virtual StatusCode clearStore(size_t slotIndex) override;
49 
55  virtual StatusCode setNumberOfStores(size_t slots) override;
56 
61  virtual size_t getNumberOfStores() const override;
62 
69  virtual bool exists( const DataObjID& ) override;
70 
77  virtual size_t allocateStore( int evtnumber ) override;
78 
84  virtual StatusCode freeStore( size_t slotIndex ) override;
85 
86 
92  virtual size_t getPartitionNumber(int eventnumber) const override;
93 
95  virtual size_t freeSlots() override;
96 
98  virtual StatusCode initialize() override;
99  virtual StatusCode finalize() override;
100  virtual StatusCode start() override;
102 
104  HiveMgrSvc(const std::string& name, ISvcLocator* svc);
105 
106  virtual ~HiveMgrSvc() {}
107 
108 private:
117  static void setNumProcs(size_t numProcs);
118 
120  size_t m_nSlots; //property settable also by setNumberOfStores
121  std::vector<SG::HiveEventSlot> m_slots;
122  std::mutex m_mutex; //< protects m_slots access
123  std::atomic<size_t> m_freeSlots {0};
124 
125 };
126 } //namespace SG
127 #endif // STOREGATE_HIVEMGRSVC_H
SG::HiveMgrSvc::initialize
virtual StatusCode initialize() override
Definition: SGHiveMgrSvc.cxx:181
SG::HiveMgrSvc::getPartitionNumber
virtual size_t getPartitionNumber(int eventnumber) const override
Get the slot number corresponding to a given event.
Definition: SGHiveMgrSvc.cxx:149
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
SG::HiveMgrSvc::m_hiveStore
ServiceHandle< StoreGateSvc > m_hiveStore
Definition: SGHiveMgrSvc.h:119
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
SG::HiveMgrSvc::finalize
virtual StatusCode finalize() override
Definition: SGHiveMgrSvc.cxx:219
HltEventLoopMgr
AthenaMT event loop manager for running HLT online.
Definition: HltEventLoopMgr.h:73
SG::HiveMgrSvc::m_slots
std::vector< SG::HiveEventSlot > m_slots
Definition: SGHiveMgrSvc.h:121
SG::HiveMgrSvc::m_freeSlots
std::atomic< size_t > m_freeSlots
Definition: SGHiveMgrSvc.h:123
SG::HiveMgrSvc::TestSGHiveMgrSvc
friend class TestSGHiveMgrSvc
Definition: SGHiveMgrSvc.h:31
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:125
SG::HiveMgrSvc
Definition: SGHiveMgrSvc.h:30
SG::HiveMgrSvc::exists
virtual bool exists(const DataObjID &) override
Check if a data object exists in store.
Definition: SGHiveMgrSvc.cxx:160
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::HiveMgrSvc::HiveMgrSvc
HiveMgrSvc(const std::string &name, ISvcLocator *svc)
Standard Service Constructor. sets active store to default event store.
Definition: SGHiveMgrSvc.cxx:17
SG::HiveMgrSvc::start
virtual StatusCode start() override
Definition: SGHiveMgrSvc.cxx:233
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
SG::HiveMgrSvc::selectStore
virtual StatusCode selectStore(size_t slotIndex) override
Activate an given 'slot' for all subsequent calls within the same thread id.
Definition: SGHiveMgrSvc.cxx:46
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
SG::HiveMgrSvc::allocateStore
virtual size_t allocateStore(int evtnumber) override
Allocate a store slot for new event.
Definition: SGHiveMgrSvc.cxx:98
SG::HiveMgrSvc::m_nSlots
size_t m_nSlots
Definition: SGHiveMgrSvc.h:120
SG::HiveMgrSvc::freeStore
virtual StatusCode freeStore(size_t slotIndex) override
Free a store slot.
Definition: SGHiveMgrSvc.cxx:125
SG::HiveMgrSvc::setNumProcs
static void setNumProcs(size_t numProcs)
Set number of concurrent processes.
Definition: SGHiveMgrSvc.cxx:35
SG::HiveMgrSvc::m_mutex
std::mutex m_mutex
Definition: SGHiveMgrSvc.h:122
SG::HiveMgrSvc::getNumberOfStores
virtual size_t getNumberOfStores() const override
Get the number of 'slots'.
Definition: SGHiveMgrSvc.cxx:86
SG::HiveMgrSvc::setNumberOfStores
virtual StatusCode setNumberOfStores(size_t slots) override
Set the number of 'slots'.
Definition: SGHiveMgrSvc.cxx:72
SG::HiveMgrSvc::clearStore
virtual StatusCode clearStore(size_t slotIndex) override
Clear a given 'slot'.
Definition: SGHiveMgrSvc.cxx:57
SGHiveEventSlot.h
StoreGateSvc.h
SG::HiveMgrSvc::~HiveMgrSvc
virtual ~HiveMgrSvc()
Definition: SGHiveMgrSvc.h:106
SG::HiveMgrSvc::freeSlots
virtual size_t freeSlots() override
Get free slots number.
Definition: SGHiveMgrSvc.cxx:156
ServiceHandle< StoreGateSvc >