From: richterm Date: Wed, 30 May 2007 16:52:41 +0000 (+0000) Subject: changed from usage of TList to private list due to crashes in TList when instantiated... X-Git-Url: http://git.uio.no/git/?p=u%2Fmrichter%2FAliRoot.git;a=commitdiff_plain;h=7617ca1eb00f97bae0d50349ff99cab933e1da61 changed from usage of TList to private list due to crashes in TList when instantiated at library load --- diff --git a/HLT/BASE/AliHLTModuleAgent.cxx b/HLT/BASE/AliHLTModuleAgent.cxx index 8101ef52449..adf398ca36c 100644 --- a/HLT/BASE/AliHLTModuleAgent.cxx +++ b/HLT/BASE/AliHLTModuleAgent.cxx @@ -51,9 +51,6 @@ AliHLTModuleAgent& AliHLTModuleAgent::operator=(const AliHLTModuleAgent&) return *this; } -TList AliHLTModuleAgent::fgAgentList; -TObjLink* AliHLTModuleAgent::fgCurrentLnk=NULL; - AliHLTModuleAgent::~AliHLTModuleAgent() { // see header file for function documentation @@ -64,28 +61,29 @@ void AliHLTModuleAgent::PrintStatus(const char* agent) { // see header file for function documentation AliHLTLogging log; - if (agent) { - TObject* pAgent=fgAgentList.FindObject(agent); - if (pAgent) { - log.Logging(kHLTLogInfo, "AliHLTModuleAgent::PrintStatus", "module agents", - "agent %s available", pAgent->GetName()); - } else { - log.Logging(kHLTLogInfo, "AliHLTModuleAgent::PrintStatus", "module agents", - "agent %s not found", agent); - } + if (agent) { + AliHLTModuleAgent* pCurrent=fAnchor; + while (pCurrent!=NULL && strcmp(pCurrent->GetName(), agent)!=0) pCurrent=pCurrent->fpNext; + if (pCurrent) { + log.Logging(kHLTLogInfo, "AliHLTModuleAgent::PrintStatus", "module agents", + "agent %s available", pCurrent->GetName()); + } else { + log.Logging(kHLTLogInfo, "AliHLTModuleAgent::PrintStatus", "module agents", + "agent %s not found", agent); + } } else { - TObjLink* lnk=fgAgentList.FirstLink(); - log.Logging(kHLTLogInfo, "AliHLT", "", "-----------------------"); - log.Logging(kHLTLogInfo, "AliHLT", "", "available module agents"); - if (lnk==NULL) - log.Logging(kHLTLogInfo, "AliHLT", "", " none"); - while (lnk) { - TString msg; - msg.Form(" %s : %p", ((AliHLTModuleAgent*)lnk->GetObject())->GetName(), lnk->GetObject()); - log.Logging(kHLTLogInfo, "AliHLT", "", msg.Data()); - lnk=lnk->Next(); - } - log.Logging(kHLTLogInfo, "AliHLT", "", "-----------------------"); + AliHLTModuleAgent* pCurrent=fAnchor; + log.Logging(kHLTLogInfo, "AliHLT", "", "-----------------------"); + log.Logging(kHLTLogInfo, "AliHLT", "", "available module agents"); + if (pCurrent==NULL) + log.Logging(kHLTLogInfo, "AliHLT", "", " none"); + while (pCurrent) { + TString msg; + msg.Form(" %s : %p", pCurrent->GetName(), pCurrent); + log.Logging(kHLTLogInfo, "AliHLT", "", msg.Data()); + pCurrent=pCurrent->fpNext; + } + log.Logging(kHLTLogInfo, "AliHLT", "", "-----------------------"); } } @@ -132,21 +130,22 @@ int AliHLTModuleAgent::RegisterComponents(AliRunLoader* runloader) const return 0; } +AliHLTModuleAgent* AliHLTModuleAgent::fAnchor=NULL; +AliHLTModuleAgent* AliHLTModuleAgent::fCurrent=NULL; +int AliHLTModuleAgent::fCount=0; + AliHLTModuleAgent* AliHLTModuleAgent::GetFirstAgent() { // see header file for function documentation - fgCurrentLnk=fgAgentList.FirstLink(); - if (fgCurrentLnk==NULL) return NULL; - return (AliHLTModuleAgent*)fgCurrentLnk->GetObject(); + fCurrent=fAnchor; + return fAnchor; } AliHLTModuleAgent* AliHLTModuleAgent::GetNextAgent() { // see header file for function documentation - if (fgCurrentLnk==NULL) return NULL; - fgCurrentLnk=fgCurrentLnk->Next(); - if (fgCurrentLnk==NULL) return NULL; - return (AliHLTModuleAgent*)fgCurrentLnk->GetObject(); + if (fCurrent!=NULL) fCurrent=fCurrent->fpNext; + return fCurrent; } int AliHLTModuleAgent::Register(AliHLTModuleAgent* pAgent) @@ -154,11 +153,15 @@ int AliHLTModuleAgent::Register(AliHLTModuleAgent* pAgent) // see header file for function documentation AliHLTLogging log; if (!pAgent) return -EINVAL; - if (fgAgentList.FindObject(pAgent)==NULL) { - log.Logging(kHLTLogDebug, "AliHLTModuleAgent::Register", "", "module agent %p registered", pAgent); - fgAgentList.Add(pAgent); + if (fAnchor==NULL) { + fAnchor=pAgent; + } else { + pAgent->fpNext=fAnchor; + fAnchor=pAgent; } - return 0; + // log.Logging(kHLTLogDebug, "AliHLTModuleAgent::Register", "", "module agent %p registered", pAgent); + fCount++; + return 0; } int AliHLTModuleAgent::Unregister(AliHLTModuleAgent* pAgent) @@ -166,10 +169,21 @@ int AliHLTModuleAgent::Unregister(AliHLTModuleAgent* pAgent) // see header file for function documentation AliHLTLogging log; if (!pAgent) return -EINVAL; - if (fgAgentList.FindObject(pAgent)!=NULL) { + fCurrent=NULL; + AliHLTModuleAgent* prev=NULL; + AliHLTModuleAgent* handler=fAnchor; + while (handler!=NULL && handler!=pAgent) { + prev=handler; + handler=handler->fpNext; + } + if (handler) { + if (prev==NULL) { + fAnchor=handler->fpNext; + } else { + prev->fpNext=handler->fpNext; + } log.Logging(kHLTLogDebug, "AliHLTModuleAgent::Unregister", "", "module agent %p removed", pAgent); - fgAgentList.Remove(pAgent); - } else { + fCount--; } return 0; } diff --git a/HLT/BASE/AliHLTModuleAgent.h b/HLT/BASE/AliHLTModuleAgent.h index 1171aeb4cea..fabc439549e 100644 --- a/HLT/BASE/AliHLTModuleAgent.h +++ b/HLT/BASE/AliHLTModuleAgent.h @@ -183,12 +183,18 @@ class AliHLTModuleAgent : public TObject, public AliHLTLogging { static int Unregister(AliHLTModuleAgent* pAgent); /** the list of active agents */ - static TList fgAgentList; + static AliHLTModuleAgent* fAnchor; //! transient + + /** next element in the list */ + AliHLTModuleAgent* fpNext; //! transient /** the current object link (list position) */ - static TObjLink* fgCurrentLnk; + static AliHLTModuleAgent* fCurrent; //! transient + + /** number of agents */ + static int fCount; //! transient - ClassDef(AliHLTModuleAgent, 0); + ClassDef(AliHLTModuleAgent, 1); }; #endif diff --git a/HLT/BASE/AliHLTOfflineInterface.cxx b/HLT/BASE/AliHLTOfflineInterface.cxx index 59ead57a9c3..1d526b00575 100644 --- a/HLT/BASE/AliHLTOfflineInterface.cxx +++ b/HLT/BASE/AliHLTOfflineInterface.cxx @@ -40,8 +40,9 @@ AliHLTOfflineInterface::AliHLTOfflineInterface() // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt } -TList AliHLTOfflineInterface::fgList; -TObjLink* AliHLTOfflineInterface::fgCurrentLnk=NULL; +AliHLTOfflineInterface* AliHLTOfflineInterface::fAnchor=NULL; +AliHLTOfflineInterface* AliHLTOfflineInterface::fCurrent=NULL; +int AliHLTOfflineInterface::fCount=0; AliRunLoader* AliHLTOfflineInterface::fgpRunLoader=NULL; AliRawReader* AliHLTOfflineInterface::fgpRawReader=NULL; @@ -129,18 +130,17 @@ int AliHLTOfflineInterface::SetParamsToComponents(AliRunLoader* runLoader, AliRa int count=0; fgpRunLoader=runLoader; fgpRawReader=rawReader; - fgCurrentLnk=fgList.FirstLink(); - while (fgCurrentLnk!=NULL) { - AliHLTOfflineInterface* pComponent=reinterpret_cast(fgCurrentLnk->GetObject()); + AliHLTOfflineInterface* pCurrent=fAnchor; + while (pCurrent!=NULL) { int iLocal=0; - if (pComponent) iLocal=pComponent->SetParams(runLoader, rawReader); + if (pCurrent) iLocal=pCurrent->SetParams(runLoader, rawReader); if (iLocal<0) { log.LoggingVarargs(kHLTLogWarning, "AliHLTOfflineInterface","SetParamsToComponents", __FILE__, __LINE__, - "parameter initialization failed for component %p with result %d", pComponent, iLocal); + "parameter initialization failed for component %p with result %d", pCurrent, iLocal); if (iResult>=0) iResult=iLocal; } count++; - fgCurrentLnk=fgCurrentLnk->Next(); + pCurrent=pCurrent->fpNext; } if (iResult>=0) { // log.LoggingVarargs(kHLTLogInfo, "AliHLTOfflineInterface","SetParamsToComponents", __FILE__, __LINE__, @@ -153,15 +153,14 @@ int AliHLTOfflineInterface::ResetComponents() { // see header file for class documentation int iResult=0; - fgCurrentLnk=fgList.FirstLink(); - while (fgCurrentLnk!=NULL) { - AliHLTOfflineInterface* pComponent=reinterpret_cast(fgCurrentLnk->GetObject()); + AliHLTOfflineInterface* pCurrent=fAnchor; + while (pCurrent!=NULL) { int iLocal=0; - if (pComponent) iLocal=pComponent->Reset(); + if (pCurrent) iLocal=pCurrent->Reset(); if (iLocal<0) { if (iResult>=0) iResult=iLocal; } - fgCurrentLnk=fgCurrentLnk->Next(); + pCurrent=pCurrent->fpNext; } return iResult; } @@ -170,21 +169,20 @@ int AliHLTOfflineInterface::FillComponentESDs(int eventNo, AliRunLoader* runLoad { // see header file for class documentation int iResult=0; - fgCurrentLnk=fgList.FirstLink(); - while (fgCurrentLnk!=NULL) { - AliHLTOfflineInterface* pComponent=reinterpret_cast(fgCurrentLnk->GetObject()); + AliHLTOfflineInterface* pCurrent=fAnchor; + while (pCurrent!=NULL) { int iLocal=0; - if (pComponent) { - pComponent->SetESD(eventNo, esd); - if (pComponent->GetRunLoader()!=runLoader) { - //HLTWarning("runLoader missmatch: component %p was reconstructed with runLoader %p, but got %p now", pComponent, pComponent->GetRunLoader(), runLoader); + if (pCurrent) { + pCurrent->SetESD(eventNo, esd); + if (pCurrent->GetRunLoader()!=runLoader) { + //HLTWarning("runLoader missmatch: component %p was reconstructed with runLoader %p, but got %p now", pCurrent, pCurrent->GetRunLoader(), runLoader); } - iLocal=pComponent->FillESD(eventNo, runLoader, esd); + iLocal=pCurrent->FillESD(eventNo, runLoader, esd); } if (iLocal<0) { if (iResult>=0) iResult=iLocal; } - fgCurrentLnk=fgCurrentLnk->Next(); + pCurrent=pCurrent->fpNext; } return iResult; } @@ -193,10 +191,13 @@ int AliHLTOfflineInterface::Register(AliHLTOfflineInterface* me) { // see header file for function documentation int iResult=0; - if (fgList.FindObject(me->GetName())==NULL) { - fgList.Add(me); + if (fAnchor==NULL) { + fAnchor=me; } else { + me->fpNext=fAnchor; + fAnchor=me; } + fCount++; return iResult; } @@ -204,9 +205,20 @@ int AliHLTOfflineInterface::Unregister(AliHLTOfflineInterface* me) { // see header file for function documentation int iResult=0; - if (fgList.FindObject(me)!=NULL) { - fgList.Remove(me); - } else { + fCurrent=NULL; + AliHLTOfflineInterface* prev=NULL; + AliHLTOfflineInterface* handler=fAnchor; + while (handler!=NULL && handler!=me) { + prev=handler; + handler=handler->fpNext; + } + if (handler) { + if (prev==NULL) { + fAnchor=handler->fpNext; + } else { + prev->fpNext=handler->fpNext; + } + fCount--; } return iResult; } diff --git a/HLT/BASE/AliHLTOfflineInterface.h b/HLT/BASE/AliHLTOfflineInterface.h index cbd3af96860..22a6b64c3ae 100644 --- a/HLT/BASE/AliHLTOfflineInterface.h +++ b/HLT/BASE/AliHLTOfflineInterface.h @@ -149,12 +149,6 @@ protected: static int Unregister(AliHLTOfflineInterface* me); private: - /** the list of active interfaces */ - static TList fgList; // see above - - /** the current object link (list position) */ - static TObjLink* fgCurrentLnk; // see above - /** global AliRoot run loader instance (for all components) */ static AliRunLoader* fgpRunLoader; //! transient /** global AliRoot raw reader instance (for all components) */ @@ -167,7 +161,19 @@ protected: /** AliRoot HLT ESD instance */ AliESD* fpESD; //! transient - ClassDef(AliHLTOfflineInterface, 1); + /** the list of active interfaces */ + static AliHLTOfflineInterface* fAnchor; //! transient + + /** next element in the list */ + AliHLTOfflineInterface* fpNext; //! transient + + /** the current element */ + static AliHLTOfflineInterface* fCurrent; //! transient + + /** number of interfaces */ + static int fCount; //! see above + + ClassDef(AliHLTOfflineInterface, 2); }; #endif