]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
schedule registration of configuration if handler is inactive, and register when...
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 3 May 2011 05:26:13 +0000 (05:26 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 3 May 2011 05:26:13 +0000 (05:26 +0000)
HLT/BASE/AliHLTConfigurationHandler.cxx
HLT/BASE/AliHLTConfigurationHandler.h

index 9b0c228ab89b6f00bca2d44332fd98ad575b7625..256d970bde358efac6099199dd16c66fd4cd0725 100644 (file)
@@ -47,6 +47,7 @@ ClassImp(AliHLTConfigurationHandler)
 AliHLTConfigurationHandler::AliHLTConfigurationHandler()
   : AliHLTLogging()
   , fgListConfigurations()
+  , fgListScheduledRegistrations()
   , fFlags(0)
 {
   // see header file for class documentation
@@ -67,6 +68,7 @@ AliHLTConfigurationHandler::~AliHLTConfigurationHandler()
     fgListConfigurations.Remove(lnk);
     delete pConf;
   }
+  fgListScheduledRegistrations.Delete();
 }
 
 AliHLTConfigurationHandler* AliHLTConfigurationHandler::fgpInstance=NULL;
@@ -103,26 +105,30 @@ int AliHLTConfigurationHandler::RegisterConfiguration(AliHLTConfiguration* pConf
   // see header file for function documentation
   int iResult=0;
   if (pConf) {
-    AliHLTConfiguration* pExisting=NULL;
-    if ((pExisting=FindConfiguration(pConf->GetName())) == NULL) {
-      AliHLTConfiguration* pClone=new AliHLTConfiguration(*pConf);
-      fgListConfigurations.Add(pClone);
-      HLTDebug("configuration \"%s\" (%p) registered from %p", pClone->GetName(), pClone, pConf);
-
-      // mark all configurations with unresolved dependencies for re-evaluation
-      TObjLink* lnk=fgListConfigurations.FirstLink();
-      while (lnk) {
-       AliHLTConfiguration* pSrc=(AliHLTConfiguration*)lnk->GetObject();
-       if (pSrc && pSrc!=pClone && pSrc->SourcesResolved()!=1) {
-         pSrc->InvalidateSources();
-       }
-       lnk=lnk->Next();
-      }
-    } else {
-      if ((*pExisting)!=(*pConf)) {
-      iResult=-EEXIST;
-      HLTWarning("configuration \"%s\" already registered with different properties", pConf->GetName());
+    AliHLTConfiguration* pClone=new AliHLTConfiguration(*pConf);
+    if (IsActive()) {      
+      AliHLTConfiguration* pExisting=NULL;
+      if ((pExisting=FindConfiguration(pConf->GetName())) == NULL) {
+        fgListConfigurations.Add(pClone);
+        HLTDebug("configuration \"%s\" (%p) registered from %p", pClone->GetName(), pClone, pConf);
+
+        // mark all configurations with unresolved dependencies for re-evaluation
+        TObjLink* lnk=fgListConfigurations.FirstLink();
+        while (lnk) {
+          AliHLTConfiguration* pSrc=(AliHLTConfiguration*)lnk->GetObject();
+          if (pSrc && pSrc!=pClone && pSrc->SourcesResolved()!=1) {
+            pSrc->InvalidateSources();
+          }
+          lnk=lnk->Next();
+        }
+      } else {
+        if ((*pExisting)!=(*pConf)) {
+          iResult=-EEXIST;
+          HLTWarning("configuration \"%s\" already registered with different properties", pConf->GetName());
+        }
       }
+    } else if (IsScheduling()) {
+      fgListScheduledRegistrations.Add(pClone);
     }
   } else {
     iResult=-EINVAL;
@@ -236,6 +242,29 @@ AliHLTConfiguration* AliHLTConfigurationHandler::FindConfiguration(const char* i
   return pConf;
 }
 
+int AliHLTConfigurationHandler::Deactivate(bool schedule) {
+  // see header file for function documentation
+  fFlags|=kInactive;
+  if (schedule)
+    fFlags|=kScheduling;
+  return 0;
+}
+
+int AliHLTConfigurationHandler::Activate() {
+  // see header file for function documentation
+  fFlags&=~kInactive;
+  if (IsScheduling()) {
+    fFlags&=~kScheduling;
+    TObjLink *lnk = fgListScheduledRegistrations.FirstLink();
+    while (lnk) {
+      RegisterConfiguration((AliHLTConfiguration*)lnk->GetObject());
+      lnk = lnk->Next();
+    }
+    ClearScheduledRegistrations();
+  }
+  return 0;
+}
+
 int AliHLTConfigurationHandler::MissedRegistration(const char* name)
 {
   /// indicate a failed attempt to register because of unavailable global instance
index d95a9813c20a0ca20bd4e2291085623db026839c..d66542a8bd6c029f5f661656ad42bb015feb03f0 100644 (file)
@@ -24,8 +24,8 @@ class TMap;
  * @brief Global Handling of HLT configurations.
  *
  * This class implements the global handling of @ref AliHLTConfiguration objects.
- * It is a list of all configuartion descriptor currently available in the system.
- * Each @ref AliHLTConfiguration object is registerd automatically with the
+ * It is a list of all configuration descriptors currently available in the system.
+ * Each @ref AliHLTConfiguration object is registered automatically with the
  * handler and put into the list.
  *
  * @note This class is only used for the @ref alihlt_system.
@@ -58,27 +58,36 @@ class AliHLTConfigurationHandler : public AliHLTLogging {
 
   /**
    * Get the instance of the global singleton.
-   * Does not create the global instance. Returns NULL if status of the global
-   * instance is 'inactive'.
+   * Does not create the global instance.
    */
   static AliHLTConfigurationHandler* Instance() {
-    if (!fgpInstance || !fgpInstance->IsActive()) return NULL;
+    if (!fgpInstance) return NULL;
     return fgpInstance;
   }
 
   /*****************************************************************************
-   * activation, effects the availability of the global singleton via
-   * AliHLTConfigurationHandler::Instance()
+   * activation, affects if the handler will accept new registrations
    */
 
-  /// deactivate the handler, AliHLTConfiguration objects will not register
-  int Deactivate() {fFlags|=kInactive; return 0;}
+  /**
+   * Deactivate the handler, AliHLTConfiguration objects will not register
+   * @param schedule     Store and schedule registrations pending reactivation
+   */
+  int Deactivate(bool schedule=false);
 
-  /// activate the handler, AliHLTConfiguration objects will register again
-  int Activate() {fFlags&=~kInactive; return 0;}
+  /**
+   * Activate the handler, AliHLTConfiguration objects will register again
+   */
+  int Activate();
 
   /// check if active
   bool IsActive() const {return (fFlags&kInactive)==0;}
+  
+  /// check if scheduling
+  bool IsScheduling() const {return (fFlags&kScheduling)>0;}
+  
+  /// clear scheduled registrations
+  void ClearScheduledRegistrations() {fgListScheduledRegistrations.Delete();}
 
   /// signal a missed registration
   static int MissedRegistration(const char* name=NULL);
@@ -158,11 +167,15 @@ class AliHLTConfigurationHandler : public AliHLTLogging {
 
  private:
   enum {
-    kInactive = 0x1
+    kInactive = 0x1,
+    kScheduling = 0x2
   };
 
   /** the list of registered configurations */
   TList fgListConfigurations;                                      // see above
+  
+  /** list of configurations scheduled to be registered */
+  TList fgListScheduledRegistrations;                              // see above
 
   /** status of the handler */
   unsigned fFlags;                                                 //! transient