16 #include "ThreadLocalStorage.h" 17 #include "boost/callable_traits.hpp" 18 #include "tbb/concurrent_queue.h" 19 #include "tbb/mutex.h" 20 #include "tbb/recursive_mutex.h" 36 struct Partition final {
47 return dataProvider.get();
51 return dataManager.get();
57 template <
typename T,
typename Mutex = tbb::recursive_mutex,
typename ReadLock =
typename Mutex::scoped_lock,
58 typename WriteLock = ReadLock>
65 decltype(
auto ) with_lock( F&& f ) {
66 WriteLock
lock{m_mtx};
70 decltype(
auto ) with_lock( F&& f )
const {
76 template <
typename Fun>
77 auto with_lock( Fun&& f ) {
78 return [f = std::forward<Fun>( f )](
auto& p ) -> decltype(
auto ) {
return p.with_lock( f ); };
81 template <
typename ContainerOfSynced,
typename Fun>
82 void for_( ContainerOfSynced&
c, Fun&& f ) {
87 TTHREAD_TLS( Synced<Partition>* ) s_current =
nullptr;
94 using argument_t = std::tuple_element_t<0, boost::callable_traits::args_t<F>>;
97 template <
typename Fun>
100 return s_current->with_lock( [&]( Partition& p ) {
101 auto* svc = p.get<std::decay_t<detail::argument_t<Fun>>>();
127 "enable incidents on data creation requests"};
140 using extends::extends;
148 p.dataManager->release();
149 p.dataProvider->release();
204 for_(
m_partitions, []( Partition& p ) { p.dataManager->clearStore().ignore(); } );
239 if ( pDataLoader ) pDataLoader->
addRef();
248 for_(
m_partitions, [&]( Partition& p ) { p.dataProvider->addPreLoadItem( item ); } );
253 for_(
m_partitions, [&]( Partition& p ) { p.dataProvider->removePreLoadItem( item ); } );
258 for_(
m_partitions, [&]( Partition& p ) { p.dataProvider->resetPreLoad(); } );
332 return m_partitions[partition].with_lock( []( Partition& p ) {
return p.dataManager->clearStore(); } );
344 warning() <<
"Too late to change the number of slots!" <<
endmsg;
364 size_t slot = std::string::npos;
366 assert( slot != std::string::npos );
368 m_partitions[slot].with_lock( [evtnumber]( Partition& p ) {
369 assert( p.eventNumber == -1 );
370 p.eventNumber = evtnumber;
379 auto prev =
m_partitions[partition].with_lock( []( Partition& p ) {
return std::exchange( p.eventNumber, -1 ); } );
388 with_lock( [eventnumber](
const Partition& p ) {
return p.eventNumber == eventnumber; } ) );
395 error() <<
"Failed to retrieve data loader " 432 error() <<
"Unable to initialize base class" <<
endmsg;
446 for (
size_t i = 0; i <
m_slots; i++ ) {
458 error() <<
"Failed to instantiate DataSvc as store partition" <<
endmsg;
462 p.dataProvider = svc;
475 error() <<
"Unable to reinitialize base class" <<
endmsg;
481 error() <<
"Failed to attach necessary services." <<
endmsg;
virtual StatusCode traverseTree(IDataStoreAgent *pAgent)=0
Analyse by traversing all data objects in the data store.
StatusCode updateObject(IRegistry *pDirectory) override
Update object identified by its directory entry.
Gaudi::Property< int > m_outputLevel
StatusCode initialize() override
Gaudi::Property< std::string > m_rootName
StatusCode unregisterObject(DataObject *pObj) override
Unregister object from the data store.
StatusCode registerAddress(std::string_view path, IOpaqueAddress *pAddr) override
IDataManagerSvc: Register object address with the data store.
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
StatusCode retrieveObject(IRegistry *parent, std::string_view path, DataObject *&pObj) override
Retrieve object from data store.
size_t allocateStore(int evtnumber) override
Allocate a store partition for a given event number.
virtual StatusCode objectLeaves(const DataObject *pObject, std::vector< IRegistry * > &refLeaves)=0
Explore the object store: retrieve all leaves attached to the object The object is identified by its ...
virtual StatusCode registerAddress(std::string_view fullPath, IOpaqueAddress *pAddress)=0
Register object address with the data store.
virtual StatusCode linkObject(IRegistry *from, std::string_view objPath, DataObject *toObj)=0
Add a link to another object.
Gaudi::Property< bool > m_enableFaultHdlr
StatusCode finalize() override
Implementation of property with value of concrete type.
Gaudi::StateMachine::State FSMState() const override
StatusCode setProperty(const Gaudi::Details::PropertyBase &p) override
set the property form another property
virtual StatusCode traverseSubTree(std::string_view sub_tree_path, IDataStoreAgent *pAgent)=0
Analyse by traversing all data objects below the sub tree identified by its full path name.
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
StatusCode freeStore(size_t partition) override
Free a store partition.
StatusCode registerObject(std::string_view parent, std::string_view obj, DataObject *pObj) override
Register object with the data store.
StatusCode traverseSubTree(std::string_view path, IDataStoreAgent *pAgent) override
Analyze by traversing all data objects below the sub tree.
StatusCode unregisterObject(std::string_view path) override
Unregister object from the data store.
StatusCode clearStore(size_t partition) override
Remove all data objects in one 'slot' of the data store.
StatusCode linkObject(std::string_view fullPath, DataObject *to) override
Add a link to another object.
StatusCode linkObject(IRegistry *from, std::string_view objPath, DataObject *to) override
Add a link to another object.
StatusCode unregisterObject(DataObject *pObj, std::string_view path) override
Unregister object from the data store.
virtual StatusCode setRoot(std::string root_name, DataObject *pObject)=0
Initialize data store for new event by giving new event path.
virtual StatusCode unregisterAddress(std::string_view fullPath)=0
Unregister object address from the data store.
IAddressCreator interface definition.
virtual StatusCode setDataProvider(IDataProviderSvc *pService)=0
Set Data provider service.
Gaudi::Property< std::string > m_loader
StatusCode unregisterAddress(IRegistry *pParent, std::string_view path) override
IDataManagerSvc: Unregister object address from the data store.
constexpr static const auto SUCCESS
virtual StatusCode preLoad()=0
Load all preload items of the list.
StatusCode resetPreLoad() override
Clear the preload list.
StatusCode finalize() override
Service initialisation.
StatusCode clearSubTree(DataObject *pObject) override
Remove all data objects below the sub tree identified.
StatusCode objectParent(const IRegistry *pObject, IRegistry *&refpParent) override
IDataManagerSvc: Explore the object store: retrieve the object's parent.
StatusCode addPreLoadItem(const DataStoreItem &item) override
Add an item to the preload list.
StatusCode updateObject(DataObject *pObj) override
Update object.
std::vector< Synced< Partition > > m_partitions
Datastore partitions.
StatusCode clearSubTree(std::string_view path) override
Remove all data objects below the sub tree identified.
auto get(const Handle &handle, const Algo &, const EventContext &) -> decltype(details::deref(handle.get()))
Data provider interface definition.
StatusCode preLoad() override
load all preload items of the list
Description of the DataStoreItem class.
StatusCode unregisterAddress(std::string_view path) override
IDataManagerSvc: Unregister object address from the data store.
StatusCode unlinkObject(std::string_view path) override
Remove a link to another object.
size_t freeSlots() override
Get free slots number.
virtual StatusCode objectParent(const DataObject *pObject, IRegistry *&refpParent)=0
IDataManagerSvc: Explore the object store: retrieve the object's parent.
StatusCode clearStore() override
IDataManagerSvc: Remove all data objects in the data store.
virtual StatusCode unlinkObject(IRegistry *from, std::string_view objPath)=0
Remove a link to another object.
size_t getPartitionNumber(int eventnumber) const override
Get the partition number corresponding to a given event.
StatusCode selectStore(size_t partition) override
Activate a partition object. The identifies the partition uniquely.
Invalid root path object cannot be retrieved or stored.
#define DECLARE_COMPONENT(type)
StatusCode registerAddress(IRegistry *parent, std::string_view path, IOpaqueAddress *pAdd) override
IDataManagerSvc: Register object address with the data store.
virtual StatusCode unregisterObject(std::string_view fullPath)=0
Unregister object from the data store.
const std::string & name() const override
Retrieve name of the service.
virtual StatusCode clearSubTree(std::string_view sub_path)=0
Remove all data objects below the sub tree identified by its full path name.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
StatusCode detachServices()
Gaudi::Property< CLID > m_rootCLID
TupleObj.h GaudiAlg/TupleObj.h namespace with few technical implementations.
StatusCode objectLeaves(const IRegistry *pObject, std::vector< IRegistry * > &leaves) override
Explore the object store: retrieve all leaves attached to the object.
This class is used for returning status codes from appropriate routines.
typename arg_helper< lambda >::type argument_t
virtual StatusCode updateObject(IRegistry *pDirectory)=0
Update object identified by its directory entry.
CLID rootCLID() const override
IDataManagerSvc: Accessor for root event CLID.
StatusCode removePreLoadItem(const DataStoreItem &item) override
Remove an item from the preload list.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
StatusCode reinitialize() override
unsigned int CLID
Class ID definition.
size_t getNumberOfStores() const override
Get the number of event slots (copies of DataSvc objects).
Gaudi::Property< size_t > m_slots
const std::string & rootName() const override
Name for root Event.
TTHREAD_TLS(Synced< Partition > *) s_current
StatusCode attachServices()
StatusCode traverseSubTree(DataObject *pObject, IDataStoreAgent *pAgent) override
IDataManagerSvc: Analyze by traversing all data objects below the sub tree.
const StatusCode & ignore() const
Ignore/check StatusCode.
StatusCode objectParent(const DataObject *pObject, IRegistry *&refpParent) override
IDataManagerSvc: Explore the object store: retrieve the object's parent.
StatusCode setRoot(std::string path, IOpaqueAddress *pAddr) override
Initialize data store for new event by giving new event path and address of root object.
StatusCode unlinkObject(DataObject *from, std::string_view objPath) override
Remove a link to another object.
virtual StatusCode retrieveObject(IRegistry *pDirectory, std::string_view path, DataObject *&pObject)=0
Retrieve object identified by its directory entry.
virtual unsigned long release()=0
Release Interface instance.
IAddressCreator * m_addrCreator
Reference to address creator.
Generic data agent interface.
StatusCode registerObject(std::string_view fullPath, DataObject *pObject)
Register object with the data store.
Gaudi::Property< bool > m_forceLeaves
Base class used to extend a class implementing other interfaces.
StatusCode initialize() override
Service initialization.
StatusCode setRoot(std::string path, DataObject *pObj) override
Initialize data store for new event by giving new event path and root object.
StatusCode setDataLoader(IConversionSvc *pDataLoader, IDataProviderSvc *=nullptr) override
IDataManagerSvc: Pass a default data loader to the service.
constexpr static const auto FAILURE
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.
StatusCode objectLeaves(const DataObject *pObject, std::vector< IRegistry * > &leaves) override
Explore the object store: retrieve all leaves attached to the object.
StatusCode service(const std::string &name, const T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn't already exist.
StatusCode initialize() override
Service initialisation.
StatusCode traverseTree(IDataStoreAgent *pAgent) override
IDataManagerSvc: Analyze by traversing all data objects in the data store.
AttribStringParser::Iterator begin(const AttribStringParser &parser)
Opaque address interface definition.
IConversionSvc * m_dataLoader
Pointer to data loader service.
StatusCode findObject(std::string_view path, DataObject *&pObj) override
Find object identified by its full path in the data store.
A DataObject is the base class of any identifiable object on any data store.
StatusCode findObject(IRegistry *parent, std::string_view path, DataObject *&pObj) override
Find object identified by its full path in the data store.
tbb::concurrent_queue< size_t > m_freeSlots
fifo queue of free slots
StatusCode unlinkObject(IRegistry *from, std::string_view objPath) override
Remove a link to another object.
bool exists(const DataObjID &id) override
check if a data object exists in the current store
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
static GAUDI_API void setNumConcEvents(const std::size_t &nE)
StatusCode reinitialize() override
Service initialisation.
StatusCode setNumberOfStores(size_t slots) override
Set the number of event slots (copies of DataSvc objects).
~HiveWhiteBoard() override
Standard Destructor.
StatusCode registerObject(DataObject *parent, std::string_view obj, DataObject *pObj) override
Register object with the data store.