Permalink
Browse files

Allow to register automatic cleanup modules to the ConditionsManager

  • Loading branch information...
MarkusFrankATcernch committed Jun 20, 2018
1 parent 9f30000 commit fb87299244a905bfdb7e37635671f33b1da7d0b4
@@ -157,6 +157,14 @@ namespace dd4hep {
*/
void pushUpdates() const;
/// Adopt cleanup handler. If a handler is registered, it is invoked at every "prepare" step
/** Note:
* This may be convenient under certain circumstances, however at the expense of
* more flexible approaches to perform the conditions data cleanup.
* Any previously registered instance shall be deleted.
*/
void adoptCleanup(ConditionsCleanup* cleaner) const;
/// Invoke cache cleanup with user defined policy
void clean(const ConditionsCleanup& cleaner) const;
@@ -86,16 +86,16 @@ namespace dd4hep {
virtual ~ConditionsManagerObject();
/// Access to the detector description instance
Detector& detectorDescription() const { return m_detDesc; }
Detector& detectorDescription() const { return m_detDesc; }
/// Access to the data loader
ConditionsDataLoader* loader() const { return m_loader.get(); }
ConditionsDataLoader* loader() const { return m_loader.get(); }
/// Access to load flag
bool doLoadConditions() const { return m_doLoad; }
bool doLoadConditions() const { return m_doLoad; }
/// Access to flag to indicate if unloaded items should be saved to the slice (or not)
bool doOutputUnloaded() const { return m_doOutputUnloaded; }
bool doOutputUnloaded() const { return m_doOutputUnloaded; }
/// Listener invocation when a condition is registered to the cache
void onRegister(Condition condition);
@@ -164,6 +164,14 @@ namespace dd4hep {
/// Prepare all updates to the clients with the defined IOV
virtual Result prepare(const IOV& req_iov, ConditionsSlice& slice, ConditionUpdateUserContext* ctx=0) = 0;
/// Adopt cleanup handler. If a handler is registered, it is invoked at every "prepare" step
/** Note:
* This may be convenient under certain circumstances, however at the expense of
* more flexible approaches to perform the conditions data cleanup.
* Any previously registered instance shall be deleted.
*/
virtual void adoptCleanup(ConditionsCleanup* cleaner) = 0;
/// Clean conditions, which are above the age limit.
/** @return Number of conditions cleaned/removed from the IOV pool of the given type */
virtual int clean(const IOVType* typ, int max_age) = 0;
@@ -73,7 +73,9 @@ namespace dd4hep {
dd4hep_mutex_t m_poolLock;
/// Reference to update conditions pool
std::unique_ptr<UpdatePool> m_updatePool;
/// Reference to the default conditions cleanup object (if registered)
std::unique_ptr<ConditionsCleanup> m_cleaner;
public:
/// Managed pool of typed conditions indexed by IOV-type and IOV key
TypedConditionPool m_rawPool;
@@ -132,22 +134,25 @@ namespace dd4hep {
virtual ConditionsPool* registerIOV(const IOVType& typ, IOV::Key key) final;
/// Access conditions multi IOV pool by iov type
ConditionsIOVPool* iovPool(const IOVType& type) const final;
virtual ConditionsIOVPool* iovPool(const IOVType& type) const final;
/// Register new condition with the conditions store. Unlocked version, not multi-threaded
virtual bool registerUnlocked(ConditionsPool& pool, Condition cond) final;
/// Adopt cleanup handler. If a handler is registered, it is invoked at every "prepare" step
virtual void adoptCleanup(ConditionsCleanup* cleaner) final;
/// Clean conditions, which are above the age limit.
/** @return Number of conditions cleaned/removed from the IOV pool of the given type */
int clean(const IOVType* typ, int max_age) final;
virtual int clean(const IOVType* typ, int max_age) final;
/// Invoke cache cleanup with user defined policy
/** @return pair<Number of pools cleared, Number of conditions cleaned up and removed> */
std::pair<int,int> clean(const ConditionsCleanup& cleaner) final;
virtual std::pair<int,int> clean(const ConditionsCleanup& cleaner) final;
/// Full cleanup of all managed conditions.
/** @return pair<Number of pools cleared, Number of conditions cleaned up and removed> */
std::pair<int,int> clear() final;
virtual std::pair<int,int> clear() final;
/// Push all pending updates to the conditions store.
/** Note:
@@ -240,6 +240,11 @@ bool ConditionsManager::registerUnlocked(ConditionsPool& pool, Condition cond)
void ConditionsManager::pushUpdates() const {
}
/// Adopt cleanup handler. If a handler is registered, it is invoked at every "prepare" step
void ConditionsManager::adoptCleanup(ConditionsCleanup* cleaner) const {
access()->adoptCleanup(cleaner);
}
/// Clean conditions, which are above the age limit.
void ConditionsManager::clean(const IOVType* typ, int max_age) const {
access()->clean(typ, max_age);
@@ -301,6 +301,11 @@ void Manager_Type1::__get_checked_pool(const IOV& req_iov,
Errors::invalidArg().c_str());
}
/// Adopt cleanup handler. If a handler is registered, it is invoked at every "prepare" step
void Manager_Type1::adoptCleanup(ConditionsCleanup* cleaner) {
m_cleaner.reset(cleaner);
}
/// Clean conditions, which are above the age limit.
int Manager_Type1::clean(const IOVType* typ, int max_age) {
int count = 0;
@@ -466,7 +471,12 @@ Manager_Type1::prepare(const IOV& req_iov, ConditionsSlice& slice, ConditionUpda
/// First push any pending updates and register them to pending pools...
pushUpdates();
/// Now update/fill the user pool
return slice.pool->prepare(req_iov, slice, ctx);
Result res = slice.pool->prepare(req_iov, slice, ctx);
/// Invoke auto cleanup if registered
if ( m_cleaner.get() ) {
this->clean(*m_cleaner);
}
return res;
}
/// Create empty user pool object

0 comments on commit fb87299

Please sign in to comment.