5#include "GaudiKernel/ConcurrencyFlags.h"
18 ISvcLocator* svc) : base_class(name, svc),
23 declareProperty(
"NSlots",
m_nSlots,
"number of event slots");
37 Gaudi::Concurrency::ConcurrencyFlags::setNumProcs(numProcs);
49 return StatusCode::SUCCESS;
58 StatusCode
rc(StatusCode::FAILURE);
60 rc=
m_slots[slotIndex].pEvtStore->clearStore();
61 if (
rc.isSuccess())
debug() <<
"cleared store " << slotIndex <<
endmsg;
63 if (!
rc.isSuccess())
error() <<
"could not clear store " << slotIndex <<
endmsg;
74 if(FSMState() == Gaudi::StateMachine::INITIALIZED) {
75 fatal() <<
"Too late to change the number of slots!" <<
endmsg;
76 return StatusCode::FAILURE;
81 Gaudi::Concurrency::ConcurrencyFlags::setNumConcEvents( slots );
82 return StatusCode::SUCCESS;
100 error() <<
"No slots available for event number " << evtNumber <<
endmsg;
101 return std::string::npos;
103 std::scoped_lock lock{
m_mutex};
106 error() <<
"Attempt to allocate an event slot for an event that is still active: event number " << evtNumber <<
endmsg;
107 return std::string::npos;
111 <<
" allocated to event number "<< evtNumber <<
endmsg;
116 error() <<
"No slots available for event number " << evtNumber <<
endmsg;
117 return std::string::npos;
127 std::scoped_lock lock{
m_mutex};
128 if (
m_slots[slotIndex].eventNumber == -1) {
129 debug() <<
"Slot " << slotIndex <<
" is already free" <<
endmsg;
132 m_slots[slotIndex].eventNumber = -1;
136 return StatusCode::SUCCESS;
139 return StatusCode::FAILURE;
150 std::scoped_lock lock{
m_mutex};
154 return std::string::npos;
164 std::string key =
id.key();
165 key.erase(0,key.find(
'+')+1);
167 if (
id.clid() == 0) {
171 std::string cl =
id.fullKey();
172 cl.erase(cl.find(
'/'),cl.length());
174 DataObjID d2(std::move(cl),key);
175 return m_hiveStore->transientContains(d2.clid(), key);
177 return m_hiveStore->transientContains(
id.clid(), key);
185 if ( !(Service::initialize().isSuccess()) ) {
186 fatal() <<
"Unable to initialize base class" <<
endmsg;
187 return StatusCode::FAILURE;
191 fatal() <<
"Unable to get hive event store" <<
endmsg;
192 return StatusCode::FAILURE;
199 for(
size_t i = 0; i<
m_nSlots; ++i) {
200 std::ostringstream oss;
201 oss << i <<
'_' <<
m_hiveStore->currentStore()->name();
203 child->initialize().isSuccess() &&
204 0 != (pSG =
dynamic_cast<SGImplSvc*
>(child)) )
209 fatal() <<
"Unable to clone event store " << oss.str() <<
endmsg;
210 return StatusCode::FAILURE;
215 Gaudi::Concurrency::ConcurrencyFlags::setNumConcEvents(
m_nSlots );
221 info() <<
"Finalizing " << name() <<
endmsg;
226 CHECK( s.pEvtStore->finalize() );
227 s.pEvtStore->release();
230 return StatusCode::SUCCESS;
241 slot.pEvtStore->mergeStringPool (*
m_hiveStore->currentStore());
243 return StatusCode::SUCCESS;
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
__thread HiveEventSlot * s_current(0)
The Athena Transient Store API.
void setSlotNumber(int slot, int numSlots)
Set the Hive slot number for this store.
virtual StatusCode start() override
virtual size_t allocateStore(int evtnumber) override
Allocate a store slot for new event.
HiveMgrSvc(const std::string &name, ISvcLocator *svc)
Standard Service Constructor. sets active store to default event store.
virtual size_t getNumberOfStores() const override
Get the number of 'slots'.
static void setNumProcs(size_t numProcs)
Set number of concurrent processes.
virtual bool exists(const DataObjID &) override
Check if a data object exists in store.
std::atomic< size_t > m_freeSlots
virtual size_t freeSlots() override
Get free slots number.
virtual size_t getPartitionNumber(int eventnumber) const override
Get the slot number corresponding to a given event.
virtual StatusCode selectStore(size_t slotIndex) override
Activate an given 'slot' for all subsequent calls within the same thread id.
ServiceHandle< StoreGateSvc > m_hiveStore
virtual StatusCode clearStore(size_t slotIndex) override
Clear a given 'slot'.
virtual StatusCode setNumberOfStores(size_t slots) override
Set the number of 'slots'.
std::vector< SG::HiveEventSlot > m_slots
virtual StatusCode initialize() override
virtual StatusCode freeStore(size_t slotIndex) override
Free a store slot.
virtual StatusCode finalize() override
static void setSlot(SG::HiveEventSlot *pSlot)
set the hive event slot pointer: used by the event loop mgrs
defines an enum used by address providers to decide what kind of StoreGateSvc they are providing addr...
StatusCode clone(const IService *parent, const std::string &childName, Service *&child)
given a reference to a parent svc sets a reference to a cloned child