![]() |
The Gaudi Framework
v30r4 (9b837755)
|
Common infrastructure for classes that manage data handles and other Scheduler-known data dependencies. More...
#include <GaudiKernel/DataHandleHolderBase.h>
Public Member Functions | |
template<typename... Args> | |
DataHandleHolderBase (Args &&...args) | |
NOTE: Cannot use "using Super::Super;" due to a GCC 6 bug. More... | |
void | registerDataHandle (Gaudi::v2::DataHandle &handle) final override |
Register a data handle of this algorithm/tool. More... | |
void | addDataDependency (const DataObjID &key, AccessMode access) final override |
Add a data dependency, even after initialization. More... | |
const DataObjIDColl & | dataDependencies (AccessMode access) const final override |
Tell which whiteboard keys the algorithm will be reading or writing. More... | |
void | declare (Gaudi::v1::DataHandle &handle) override |
Declare ownership of a legacy DataHandle. More... | |
void | renounce (Gaudi::v1::DataHandle &handle) override |
Discard ownership of a legacy DataHandle. More... | |
const DataObjIDColl * | allDataDependencies () const final override |
![]() | |
void * | i_cast (const InterfaceID &tid) const override |
Implementation of IInterface::i_cast. More... | |
StatusCode | queryInterface (const InterfaceID &ti, void **pp) override |
Implementation of IInterface::queryInterface. More... | |
std::vector< std::string > | getInterfaceNames () const override |
Implementation of IInterface::getInterfaceNames. More... | |
Protected Types | |
enum | CircularDepAction { CircularDepAction::Abort, CircularDepAction::Ignore } |
A circular dependency handling action. More... | |
using | DataObjIDMapping = std::function< boost::optional< DataObjID >(const DataObjID &)> |
DataObjID mapping function, with optimized identity mapping case. More... | |
using | CircularDepHandler = std::function< CircularDepAction(const DataObjID &)> |
A circular dependency handler, which can take any user-specified step (e.g. More... | |
Protected Member Functions | |
void | updateDataDependencies (const DataObjIDMapping &keyMap) |
Update the key of each registered data dependency, using a user-defined mapping from the old to the new key. More... | |
void | collectExplicitDataDependencies () |
Collect all explicit data dependencies in a single place. More... | |
StatusCode | handleCircularDataDependencies (CircularDepHandler &&circularDepHandler) |
Look for circular dependencies and let a user-specified handler deal with each of them. More... | |
void | collectImplicitDataDependencies (const IDataHandleHolder *child) |
Add the dependencies of another DataHandleHolder to our dependency list. More... | |
const DataObjIDColl & | ignoredDataDependencies (AccessMode access) const |
Tell which data dependencies have been ignored due to an empty key. More... | |
void | initializeDataHandleHolder () |
Initialize the DataHandles. More... | |
Private Types | |
using | Super = extends< BASE, IDataHandleHolder > |
using | AccessMode = Gaudi::v2::DataHandle::AccessMode |
using | DataHandleList = std::vector< Gaudi::v2::DataHandle * > |
Private Member Functions | |
bool | isNewDataDependency (const Gaudi::v2::DataHandle &handle) const |
Check if a data dependency has not been declared before (new DataHandle version) More... | |
bool | isNewDataDependency (const Gaudi::v1::DataHandle &handle) const |
Check if a data dependency has not been declared before (new DataHandle version) More... | |
template<typename KeyHolderColl > | |
void | collectDependencies (const KeyHolderColl keyHolderArray[]) |
void | collectDependencies (const std::unordered_set< Gaudi::v1::DataHandle * > legacyHandles) |
Specialization of extractDependencies for legacy DataHandles. More... | |
Static Private Member Functions | |
static size_t | accessToIndex (AccessMode access) |
Convert a data dependency access mode to its index in our internal storage. More... | |
static const DataObjID & | accessKey (const Gaudi::v2::DataHandle *handlePtr) |
Access the key of a DataHandle. More... | |
static const DataObjID & | accessKey (const DataObjID &key) |
Access the key of a DataObjID (identity function) More... | |
static const DataObjID & | accessKey (const Gaudi::v1::DataHandle *handlePtr) |
Access the key of a legacy (non-reentrant) DataHandle. More... | |
template<typename KeyHolder > | |
static void | extractKey (DataObjIDColl &validOutput, DataObjIDColl &ignoredOutput, const KeyHolder &holder) |
Extract the key of a key holder, putting empty keys on an ignore list. More... | |
template<typename KeyHolderColl > | |
static void | extractKeys (DataObjIDColl &validOutput, DataObjIDColl &ignoredOutput, const KeyHolderColl &keyHolders) |
Extract non-empty DataObjID keys from a collection of key holders. More... | |
static void | updateKey (Gaudi::v2::DataHandle *target, DataObjID &&key) |
Update the key of a DataHandle. More... | |
static void | updateKey (DataObjID &target, DataObjID &&key) |
Update the key of a DataObjID. More... | |
static void | updateKey (Gaudi::v1::DataHandle *target, DataObjID &&key) |
Update the key of a legacy (non-reentrant) DataHandle. More... | |
template<typename KeyHolderColl > | |
static void | updateDependencies (KeyHolderColl &keyHolders, const DataObjIDMapping &keyMap) |
Update the DataObjID keys of a collection of key holders. More... | |
static void | updateDependencies (DataObjIDColl &keys, const DataObjIDMapping &keyMap) |
Specialization of the above algorithm for DataObjIDColls, where updating the keys in place is not possible. More... | |
static void | updateDependencies (Gaudi::Property< DataObjIDColl > &keys, const DataObjIDMapping &keyMap) |
Specialization for properties which accesses the inner collection. More... | |
template<typename KeyHolderColl > | |
static void | updateDependencies (KeyHolderColl keyHoldersArray[], const DataObjIDMapping &keyMap) |
Specialization of the above algorithm for arrays of KeyHolderColls. More... | |
Private Attributes | |
DataHandleList | m_dataHandles [NUM_ACCESS_MODES] |
std::unordered_set< Gaudi::v1::DataHandle * > | m_legacyHandles |
Gaudi::Property< DataObjIDColl > | m_extraDeps [NUM_ACCESS_MODES] |
DataObjIDColl | m_dataDepKeys [NUM_ACCESS_MODES] |
bool | m_explicitDepsCollected = false |
Truth that all explicit data dependencies have already been collected in a single list. More... | |
DataObjIDColl | m_ignoredDataDeps [NUM_ACCESS_MODES] |
Static Private Attributes | |
static constexpr size_t | NUM_ACCESS_MODES = static_cast<size_t>( AccessMode::NUM_ACCESS_MODES ) |
Additional Inherited Members | |
![]() | |
using | base_class = extends |
Typedef to this class. More... | |
using | extend_interfaces_base = extend_interfaces< Interfaces... > |
Typedef to the base of this class. More... | |
![]() | |
using | ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids... >::type |
take union of the ext_iids of all Interfaces... More... | |
Common infrastructure for classes that manage data handles and other Scheduler-known data dependencies.
This template is intended to be used as a common base class of Algorithms and AlgTools. It factors out the bookkeeping associated with DataHandles and other explicitly declared data dependencies.
Definition at line 27 of file DataHandleHolderBase.h.
|
private |
Definition at line 30 of file DataHandleHolderBase.h.
|
protected |
A circular dependency handler, which can take any user-specified step (e.g.
logging), then produces a dependency handling action.
See CircularDepAction documentation for more information.
Definition at line 224 of file DataHandleHolderBase.h.
|
private |
Definition at line 319 of file DataHandleHolderBase.h.
|
protected |
DataObjID mapping function, with optimized identity mapping case.
This construct is used when updating the DataObjIDs associated with data dependencies, which is needed for some legacy workarounds.
The mapping function shall return boost::none when no change is required, and the modified DataObjID otherwise. This design optimizes the "no change" case, which is expected to be the norm.
Definition at line 141 of file DataHandleHolderBase.h.
|
private |
Definition at line 29 of file DataHandleHolderBase.h.
|
strongprotected |
A circular dependency handling action.
A Gaudi Algorithm with circular dependencies is not schedulable: the Scheduler will not run it until all of its data dependencies are present, but it must be run for at least one of its dependencies to be created. As a result of this deadlock, the Scheduler will stall.
Most circular dependencies are the result of a bug, in which case aborting framework initialization is the right course of action. But some circular dependencies accidentally emerge as a result of Algs having inner structure (e.g. calling multiple AlgTools/SubAlgs which generate each other's inputs). In this latter case, silently breaking up the circularity by deleting the conflicting input dependency may be the right course of action.
The user-specified circular dependency handler will notify the DataHandleHolder of its decision with this enum.
Definition at line 208 of file DataHandleHolderBase.h.
|
inline |
NOTE: Cannot use "using Super::Super;" due to a GCC 6 bug.
Definition at line 35 of file DataHandleHolderBase.h.
|
inlinestaticprivate |
Access the key of a DataHandle.
Definition at line 371 of file DataHandleHolderBase.h.
|
inlinestaticprivate |
Access the key of a DataObjID (identity function)
Definition at line 374 of file DataHandleHolderBase.h.
|
inlinestaticprivate |
Access the key of a legacy (non-reentrant) DataHandle.
Definition at line 377 of file DataHandleHolderBase.h.
|
inlinestaticprivate |
Convert a data dependency access mode to its index in our internal storage.
Definition at line 346 of file DataHandleHolderBase.h.
|
inlinefinaloverride |
Add a data dependency, even after initialization.
DataHandles are the preferred way to declare statically known data dependencies. However, there are cases in which an Algorithm's data dependencies are only known at execution time, typically when data is loaded on demand from a file or database. In this case, this method should be used to declare those dynamic data dependencies.
Definition at line 62 of file DataHandleHolderBase.h.
|
inlinefinaloverride |
Definition at line 122 of file DataHandleHolderBase.h.
|
inlineprivate |
Definition at line 408 of file DataHandleHolderBase.h.
|
inlineprivate |
Specialization of extractDependencies for legacy DataHandles.
These need special treatment, among other things because they can be both reading from and writing to a given whiteboard location.
Definition at line 420 of file DataHandleHolderBase.h.
|
inlineprotected |
Collect all explicit data dependencies in a single place.
Like updateDataDependencies(), this method must be called at a framework initialization stage where the DataObjIDs associated with data dependencies are set in stone and will not change anymore.
For optimal performance, it should also be called after any call to updateKeys (see that method's documentation for more info).
Definition at line 173 of file DataHandleHolderBase.h.
|
inlineprotected |
Add the dependencies of another DataHandleHolder to our dependency list.
This method is used to collect the implicit data dependencies that appear when an Algorithm holds inner Tools and SubAlgs, which have data dependencies themselves. We need this so that the Scheduler can see those "inner" dependencies.
This method must be called after the dependencies of the child Tool/Algorithm have been collected. This includes implicit dependencies, if applicable.
Definition at line 279 of file DataHandleHolderBase.h.
|
inlinefinaloverride |
Tell which whiteboard keys the algorithm will be reading or writing.
This function will only provide the full dependency list after it has been collected, which happens during initialization.
Definition at line 73 of file DataHandleHolderBase.h.
|
inlineoverride |
Declare ownership of a legacy DataHandle.
Definition at line 80 of file DataHandleHolderBase.h.
|
inlinestaticprivate |
Extract the key of a key holder, putting empty keys on an ignore list.
Definition at line 381 of file DataHandleHolderBase.h.
|
inlinestaticprivate |
Extract non-empty DataObjID keys from a collection of key holders.
Given an output key collection and a collection of objects that have an associated DataObjID key which can be accessed via an overload of accessKey(), extract the keys, filter out empty ones, and store the rest in the output collection.
Definition at line 399 of file DataHandleHolderBase.h.
|
inlineprotected |
Look for circular dependencies and let a user-specified handler deal with each of them.
This method must be called after explicit dependencies have been collected, as otherwise it may miss some circular dependencies.
Definition at line 232 of file DataHandleHolderBase.h.
|
inlineprotected |
Tell which data dependencies have been ignored due to an empty key.
The interface caveats described in inputKeys() also apply here.
Definition at line 289 of file DataHandleHolderBase.h.
|
inlineprotected |
Initialize the DataHandles.
This operation accesses framework services and must therefore be run after the host Algorithm or AlgTool has been sysInitialized.
Definition at line 303 of file DataHandleHolderBase.h.
|
inlineprivate |
Check if a data dependency has not been declared before (new DataHandle version)
Definition at line 349 of file DataHandleHolderBase.h.
|
inlineprivate |
Check if a data dependency has not been declared before (new DataHandle version)
Definition at line 356 of file DataHandleHolderBase.h.
|
inlinefinaloverride |
Register a data handle of this algorithm/tool.
You should not need to call this method manually, as it is automatically called by the DataHandle constructor.
Definition at line 44 of file DataHandleHolderBase.h.
|
inlineoverride |
Discard ownership of a legacy DataHandle.
Definition at line 97 of file DataHandleHolderBase.h.
|
inlineprotected |
Update the key of each registered data dependency, using a user-defined mapping from the old to the new key.
This method must be called at a framework initialization stage where the DataObjIDs associated with data dependencies are guaranteed not to change anymore. Otherwise the DataObjIDs changes brought by this update will be overwritten.
It should also be called before the explicit dependencies are collected by collectExplicitDependencies(), as otherwise the DataObjIDs modifications will be carried out in two different places, resulting in worse performance.
Definition at line 156 of file DataHandleHolderBase.h.
|
inlinestaticprivate |
Update the DataObjID keys of a collection of key holders.
Access the key from each key holder using accessKey, pass it through a user-defined transform, and if the result is different from the original key update the key using updateKey.
Definition at line 453 of file DataHandleHolderBase.h.
|
inlinestaticprivate |
Specialization of the above algorithm for DataObjIDColls, where updating the keys in place is not possible.
Definition at line 466 of file DataHandleHolderBase.h.
|
inlinestaticprivate |
Specialization for properties which accesses the inner collection.
Definition at line 477 of file DataHandleHolderBase.h.
|
inlinestaticprivate |
Specialization of the above algorithm for arrays of KeyHolderColls.
Definition at line 484 of file DataHandleHolderBase.h.
|
inlinestaticprivate |
Update the key of a DataHandle.
Definition at line 438 of file DataHandleHolderBase.h.
|
inlinestaticprivate |
Update the key of a DataObjID.
Definition at line 441 of file DataHandleHolderBase.h.
|
inlinestaticprivate |
Update the key of a legacy (non-reentrant) DataHandle.
Definition at line 444 of file DataHandleHolderBase.h.
|
private |
Definition at line 335 of file DataHandleHolderBase.h.
|
private |
Definition at line 320 of file DataHandleHolderBase.h.
|
private |
Truth that all explicit data dependencies have already been collected in a single list.
Definition at line 339 of file DataHandleHolderBase.h.
|
private |
Definition at line 331 of file DataHandleHolderBase.h.
|
private |
Definition at line 343 of file DataHandleHolderBase.h.
|
private |
Definition at line 323 of file DataHandleHolderBase.h.
|
staticprivate |
Definition at line 316 of file DataHandleHolderBase.h.