// $Id$
//**************************************************************************
-//* This file is property of and copyright by the ALICE HLT Project *
+//* This file is property of and copyright by the *
//* ALICE Experiment at CERN, All rights reserved. *
//* *
//* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
/// @brief Implementation of HLT tasks.
///
-// see header file for class documentation
-// or
-// refer to README to build package
-// or
-// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
-
-#if __GNUC__>= 3
-using namespace std;
-#endif
-
#include <cerrno>
#include <cassert>
#include <iostream>
#include "TList.h"
#include "AliHLTErrorGuard.h"
+using std::cout;
+
/** ROOT macro for the implementation of ROOT specific class methods */
ClassImp(AliHLTTask)
if ((iResult=fpDataBuffer->SetConsumer(pTgtTask->GetComponent()))>=0) {
}
} else {
- break;
iResult=-EFAULT;
+ break;
}
lnk=lnk->Next();
}
AliHLTComponent::FillEventData(evtData);
if (eventNo>=0)
evtData.fEventID=(AliHLTEventID_t)eventNo;
- if (timestamp) evtData.fEventCreation_s=timestamp;
+ if (timestamp < kMaxUInt) evtData.fEventCreation_s=timestamp;
else
evtData.fEventCreation_s=static_cast<AliHLTUInt32_t>(time(NULL));
AliHLTComponentTriggerData trigData;
return iResult;
}
+int AliHLTTask::SubscribeSourcesAndSkip()
+{
+ // function carries out the proper cleanup of the source components
+ // by subscribing and releasing
+ int iResult=0;
+ AliHLTTask* pSrcTask=NULL;
+ AliHLTTaskPList subscribedTaskList;
+
+ // cleanup the data buffer
+ if (fpDataBuffer) fpDataBuffer->Reset();
+
+ // subscribe to all source tasks
+ fBlockDataArray.clear();
+ for (TObjLink* lnk=fListDependencies.FirstLink(); lnk!=NULL; lnk=lnk->Next()) {
+ if (!lnk->GetObject()) continue;
+ pSrcTask=dynamic_cast<AliHLTTask*>(lnk->GetObject());
+ if (!pSrcTask) continue;
+ unsigned iPosition=fBlockDataArray.size();
+ if ((iResult=pSrcTask->Subscribe(this, fBlockDataArray))>0) {
+ for (unsigned i=iPosition; i<fBlockDataArray.size(); i++) {
+ subscribedTaskList.push_back(pSrcTask);
+ }
+ HLTDebug("subscribed to %d blocks of task %s (%p)", iResult, pSrcTask->GetName(), pSrcTask, iResult);
+ } else if (iResult<0) {
+ HLTError("failed to subscribe to task %s (%p) with error %d", pSrcTask->GetName(), pSrcTask, iResult);
+ }
+ }
+
+ unsigned iSourceDataBlock=0;
+ AliHLTTaskPList::iterator element;
+ while ((element=subscribedTaskList.begin())!=subscribedTaskList.end()) {
+ assert(iSourceDataBlock<fBlockDataArray.size());
+ pSrcTask=*element;
+ if (pSrcTask && iSourceDataBlock<fBlockDataArray.size()) {
+ if ((iResult=pSrcTask->Release(&fBlockDataArray[iSourceDataBlock], this))>=0) {
+ HLTDebug("successfully released segment of task %s (%p)", pSrcTask->GetName(), pSrcTask);
+ } else if (iSourceDataBlock>=fBlockDataArray.size()) {
+ HLTError("mismatch between list of subscribed tasks and block list in task %s (%p), can not release task %s (%p)", GetName(), this, pSrcTask->GetName(), pSrcTask);
+ } else {
+ HLTError("realease of task %s (%p) failed with error %d", pSrcTask->GetName(), pSrcTask, iResult);
+ }
+ }
+ subscribedTaskList.erase(element);
+ iSourceDataBlock++;
+ }
+ if (iSourceDataBlock<fBlockDataArray.size()) {
+ HLTWarning("not all subscriptions released for task %s (%p)", GetName(), this);
+ }
+
+ return 0;
+}
+
int AliHLTTask::GetNofMatchingDataBlocks(const AliHLTTask* pConsumerTask) const
{
// see header file for function documentation