]>
Commit | Line | Data |
---|---|---|
7a436c89 | 1 | // $Id$ |
2 | // splitted from AliHLTConfiguration.cxx,v 1.25 2007/10/12 13:24:47 | |
3 | /************************************************************************** | |
4 | * This file is property of and copyright by the ALICE HLT Project * | |
5 | * ALICE Experiment at CERN, All rights reserved. * | |
6 | * * | |
7 | * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> * | |
8 | * for The ALICE HLT Project. * | |
9 | * * | |
10 | * Permission to use, copy, modify and distribute this software and its * | |
11 | * documentation strictly for non-commercial purposes is hereby granted * | |
12 | * without fee, provided that the above copyright notice appears in all * | |
13 | * copies and that both the copyright notice and this permission notice * | |
14 | * appear in the supporting documentation. The authors make no claims * | |
15 | * about the suitability of this software for any purpose. It is * | |
16 | * provided "as is" without express or implied warranty. * | |
17 | **************************************************************************/ | |
18 | ||
19 | /** @file AliHLTTask.cxx | |
20 | @author Matthias Richter | |
21 | @date | |
22 | @brief Implementation of HLT tasks. | |
23 | */ | |
24 | ||
25 | // see header file for class documentation | |
26 | // or | |
27 | // refer to README to build package | |
28 | // or | |
29 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
30 | ||
31 | #if __GNUC__>= 3 | |
32 | using namespace std; | |
33 | #endif | |
34 | ||
35 | #include <cerrno> | |
36 | #include <iostream> | |
37 | #include <string> | |
38 | #include "AliHLTTask.h" | |
39 | #include "AliHLTConfiguration.h" | |
40 | #include "AliHLTComponent.h" | |
41 | #include "AliHLTComponentHandler.h" | |
42 | #include "TList.h" | |
43 | ||
44 | /** ROOT macro for the implementation of ROOT specific class methods */ | |
45 | ClassImp(AliHLTTask) | |
46 | ||
47 | AliHLTTask::AliHLTTask() | |
48 | : | |
49 | fpConfiguration(NULL), | |
50 | fpComponent(NULL), | |
51 | fpDataBuffer(NULL), | |
52 | fListTargets(), | |
53 | fListDependencies(), | |
54 | fBlockDataArray() | |
55 | { | |
56 | // see header file for class documentation | |
57 | // or | |
58 | // refer to README to build package | |
59 | // or | |
60 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
61 | } | |
62 | ||
63 | AliHLTTask::AliHLTTask(AliHLTConfiguration* pConf) | |
64 | : | |
65 | fpConfiguration(pConf), | |
66 | fpComponent(NULL), | |
67 | fpDataBuffer(NULL), | |
68 | fListTargets(), | |
69 | fListDependencies(), | |
70 | fBlockDataArray() | |
71 | { | |
72 | // see header file for function documentation | |
73 | } | |
74 | ||
75 | AliHLTTask::~AliHLTTask() | |
76 | { | |
77 | // see header file for function documentation | |
78 | TObjLink* lnk=fListDependencies.FirstLink(); | |
79 | ||
80 | while (lnk!=NULL) { | |
81 | AliHLTTask* pTask=(AliHLTTask*)lnk->GetObject(); | |
82 | pTask->UnsetTarget(this); | |
83 | lnk=lnk->Next(); | |
84 | } | |
85 | lnk=fListTargets.FirstLink(); | |
86 | ||
87 | while (lnk!=NULL) { | |
88 | AliHLTTask* pTask=(AliHLTTask*)lnk->GetObject(); | |
89 | pTask->UnsetDependency(this); | |
90 | lnk=lnk->Next(); | |
91 | } | |
92 | ||
93 | if (fpComponent) delete fpComponent; | |
94 | fpComponent=NULL; | |
95 | } | |
96 | ||
97 | int AliHLTTask::Init(AliHLTConfiguration* pConf, AliHLTComponentHandler* pCH) | |
98 | { | |
99 | // see header file for function documentation | |
100 | int iResult=0; | |
101 | if (fpConfiguration!=NULL && pConf!=NULL && fpConfiguration!=pConf) { | |
102 | HLTWarning("overriding existing reference to configuration object %p (%s) by %p", | |
103 | fpConfiguration, GetName(), pConf); | |
104 | } | |
105 | if (pConf!=NULL) fpConfiguration=pConf; | |
106 | if (fpConfiguration) { | |
107 | if (pCH) { | |
108 | int argc=0; | |
109 | const char** argv=NULL; | |
110 | if ((iResult=fpConfiguration->GetArguments(&argv))>=0) { | |
111 | argc=iResult; // just to make it clear | |
112 | // TODO: we have to think about the optional environment parameter, | |
113 | // currently just set to NULL. | |
114 | iResult=pCH->CreateComponent(fpConfiguration->GetComponentID(), NULL, argc, argv, fpComponent); | |
115 | if (fpComponent || iResult<=0) { | |
116 | //HLTDebug("component %s (%p) created", fpComponent->GetComponentID(), fpComponent); | |
117 | } else { | |
118 | HLTError("can not find component \"%s\" (%d)", fpConfiguration->GetComponentID(), iResult); | |
119 | } | |
120 | } else { | |
121 | HLTError("can not get argument list for configuration %s (%s)", fpConfiguration->GetName(), fpConfiguration->GetComponentID()); | |
122 | iResult=-EINVAL; | |
123 | } | |
124 | } else { | |
125 | HLTError("component handler instance needed for task initialization"); | |
126 | iResult=-EINVAL; | |
127 | } | |
128 | } else { | |
129 | HLTError("configuration object instance needed for task initialization"); | |
130 | iResult=-EINVAL; | |
131 | } | |
132 | return iResult; | |
133 | } | |
134 | ||
135 | int AliHLTTask::Deinit() | |
136 | { | |
137 | // see header file for function documentation | |
138 | int iResult=0; | |
139 | AliHLTComponent* pComponent=GetComponent(); | |
140 | fpComponent=NULL; | |
141 | if (pComponent) { | |
142 | //HLTDebug("delete component %s (%p)", pComponent->GetComponentID(), pComponent); | |
143 | pComponent->Deinit(); | |
144 | delete pComponent; | |
145 | } else { | |
146 | HLTWarning("task %s (%p) doesn't seem to be in initialized", GetName(), this); | |
147 | } | |
148 | return iResult; | |
149 | } | |
150 | ||
151 | const char *AliHLTTask::GetName() const | |
152 | { | |
153 | // see header file for function documentation | |
154 | if (fpConfiguration) | |
155 | return fpConfiguration->GetName(); | |
156 | return TObject::GetName(); | |
157 | } | |
158 | ||
159 | AliHLTConfiguration* AliHLTTask::GetConf() const | |
160 | { | |
161 | // see header file for function documentation | |
162 | return fpConfiguration; | |
163 | } | |
164 | ||
165 | AliHLTComponent* AliHLTTask::GetComponent() const | |
166 | { | |
167 | // see header file for function documentation | |
168 | return fpComponent; | |
169 | } | |
170 | ||
171 | AliHLTTask* AliHLTTask::FindDependency(const char* id) | |
172 | { | |
173 | // see header file for function documentation | |
174 | AliHLTTask* pTask=NULL; | |
175 | if (id) { | |
176 | pTask=(AliHLTTask*)fListDependencies.FindObject(id); | |
177 | } | |
178 | return pTask; | |
179 | } | |
180 | ||
181 | int AliHLTTask::FollowDependency(const char* id, TList* pTgtList) | |
182 | { | |
183 | // see header file for function documentation | |
184 | int iResult=0; | |
185 | if (id) { | |
186 | AliHLTTask* pDep=NULL; | |
187 | if ((pDep=(AliHLTTask*)fListDependencies.FindObject(id))!=NULL) { | |
188 | if (pTgtList) pTgtList->Add(pDep); | |
189 | iResult++; | |
190 | } else { | |
191 | TObjLink* lnk=fListDependencies.FirstLink(); | |
192 | while (lnk && iResult==0) { | |
193 | pDep=(AliHLTTask*)lnk->GetObject(); | |
194 | if (pDep) { | |
195 | if ((iResult=pDep->FollowDependency(id, pTgtList))>0) { | |
196 | if (pTgtList) pTgtList->AddFirst(pDep); | |
197 | iResult++; | |
198 | } | |
199 | } else { | |
200 | iResult=-EFAULT; | |
201 | } | |
202 | lnk=lnk->Next(); | |
203 | } | |
204 | } | |
205 | } else { | |
206 | iResult=-EINVAL; | |
207 | } | |
208 | return iResult; | |
209 | } | |
210 | ||
211 | void AliHLTTask::PrintDependencyTree(const char* id, int bFromConfiguration) | |
212 | { | |
213 | // see header file for function documentation | |
214 | HLTLogKeyword("task dependencies"); | |
215 | int iResult=0; | |
216 | TList tgtList; | |
217 | if (bFromConfiguration) { | |
218 | if (fpConfiguration) | |
219 | iResult=fpConfiguration->FollowDependency(id, &tgtList); | |
220 | else | |
221 | iResult=-EFAULT; | |
222 | } else | |
223 | iResult=FollowDependency(id, &tgtList); | |
224 | if (iResult>0) { | |
225 | HLTMessage(" task \"%s\": dependency level %d ", GetName(), iResult); | |
226 | TObjLink* lnk=tgtList.FirstLink(); | |
227 | int i=iResult; | |
228 | char* pSpace = new char[iResult+1]; | |
229 | if (pSpace) { | |
230 | memset(pSpace, 32, iResult); | |
231 | pSpace[i]=0; | |
232 | while (lnk) { | |
233 | TObject* obj=lnk->GetObject(); | |
234 | HLTMessage(" %s^-- %s ", &pSpace[i--], obj->GetName()); | |
235 | lnk=lnk->Next(); | |
236 | } | |
237 | delete [] pSpace; | |
238 | } else { | |
239 | iResult=-ENOMEM; | |
240 | } | |
241 | } | |
242 | } | |
243 | ||
244 | int AliHLTTask::SetDependency(AliHLTTask* pDep) | |
245 | { | |
246 | // see header file for function documentation | |
247 | int iResult=0; | |
248 | if (pDep) { | |
249 | if (FindDependency(pDep->GetName())==NULL) { | |
250 | fListDependencies.Add(pDep); | |
251 | } else { | |
252 | iResult=-EEXIST; | |
253 | } | |
254 | } else { | |
255 | iResult=-EINVAL; | |
256 | } | |
257 | return iResult; | |
258 | } | |
259 | ||
260 | int AliHLTTask::UnsetDependency(AliHLTTask* pDep) | |
261 | { | |
262 | // see header file for function documentation | |
263 | fListDependencies.Remove(pDep); | |
264 | if (fpConfiguration) { | |
265 | fpConfiguration->InvalidateSources(); | |
266 | } | |
267 | return 0; | |
268 | } | |
269 | ||
270 | int AliHLTTask::CheckDependencies() | |
271 | { | |
272 | // see header file for function documentation | |
273 | int iResult=0; | |
274 | AliHLTConfiguration* pSrc=fpConfiguration->GetFirstSource(); | |
275 | while (pSrc) { | |
276 | if (FindDependency(pSrc->GetName())==NULL) { | |
277 | //HLTDebug("dependency \"%s\" unresolved", pSrc->GetName()); | |
278 | iResult++; | |
279 | } | |
280 | pSrc=fpConfiguration->GetNextSource(); | |
281 | } | |
282 | return iResult; | |
283 | } | |
284 | ||
285 | ||
286 | int AliHLTTask::Depends(AliHLTTask* pTask) | |
287 | { | |
288 | // see header file for function documentation | |
289 | int iResult=0; | |
290 | if (pTask) { | |
291 | if (fpConfiguration) { | |
292 | iResult=fpConfiguration->GetSource(pTask->GetName())!=NULL; | |
293 | if (iResult>0) { | |
294 | //HLTDebug("task \"%s\" depends on \"%s\"", GetName(), pTask->GetName()); | |
295 | } else { | |
296 | //HLTDebug("task \"%s\" independend of \"%s\"", GetName(), pTask->GetName()); | |
297 | } | |
298 | } else { | |
299 | iResult=-EFAULT; | |
300 | } | |
301 | } else { | |
302 | iResult=-EINVAL; | |
303 | } | |
304 | return iResult; | |
305 | } | |
306 | ||
307 | AliHLTTask* AliHLTTask::FindTarget(const char* id) | |
308 | { | |
309 | // see header file for function documentation | |
310 | AliHLTTask* pTask=NULL; | |
311 | if (id) { | |
312 | pTask=(AliHLTTask*)fListTargets.FindObject(id); | |
313 | } | |
314 | return pTask; | |
315 | } | |
316 | ||
317 | int AliHLTTask::SetTarget(AliHLTTask* pTgt) | |
318 | { | |
319 | // see header file for function documentation | |
320 | int iResult=0; | |
321 | if (pTgt) { | |
322 | if (FindTarget(pTgt->GetName())==NULL) { | |
323 | fListTargets.Add(pTgt); | |
324 | } else { | |
325 | iResult=-EEXIST; | |
326 | } | |
327 | } else { | |
328 | iResult=-EINVAL; | |
329 | } | |
330 | return iResult; | |
331 | } | |
332 | ||
333 | int AliHLTTask::UnsetTarget(AliHLTTask* pTarget) | |
334 | { | |
335 | // see header file for function documentation | |
336 | fListTargets.Remove(pTarget); | |
337 | return 0; | |
338 | } | |
339 | ||
340 | int AliHLTTask::StartRun() | |
341 | { | |
342 | // see header file for function documentation | |
343 | int iResult=0; | |
344 | int iNofInputDataBlocks=0; | |
345 | AliHLTComponent* pComponent=GetComponent(); | |
346 | if (pComponent) { | |
347 | // determine the number of input data blocks provided from the source tasks | |
348 | TObjLink* lnk=fListDependencies.FirstLink(); | |
349 | while (lnk && iResult>=0) { | |
350 | AliHLTTask* pSrcTask=(AliHLTTask*)lnk->GetObject(); | |
351 | if (pSrcTask) { | |
352 | if ((iResult=pSrcTask->GetNofMatchingDataTypes(this))>0) { | |
353 | iNofInputDataBlocks+=iResult; | |
354 | } else if (iResult==0) { | |
355 | HLTWarning("source task %s (%p) does not provide any matching data type for task %s (%p)", pSrcTask->GetName(), pSrcTask, GetName(), this); | |
356 | } else { | |
357 | HLTError("task %s (%p): error getting matching data types for source task %s (%p)", GetName(), this, pSrcTask->GetName(), pSrcTask); | |
358 | iResult=-EFAULT; | |
359 | } | |
360 | } | |
361 | lnk=lnk->Next(); | |
362 | } | |
363 | if (iResult>=0) { | |
364 | if (fBlockDataArray.size()>0) { | |
365 | HLTWarning("block data array for task %s (%p) was not cleaned", GetName(), this); | |
366 | fBlockDataArray.resize(0); | |
367 | } | |
368 | ||
369 | // component init | |
370 | // the initialization of the component is done by the ComponentHandler after creation | |
371 | // of the component. | |
372 | //iResult=Init( AliHLTComponentEnvironment* environ, void* environ_param, int argc, const char** argv ); | |
373 | ||
374 | // allocate internal task variables for bookkeeping aso. | |
375 | // we allocate the BlockData array with at least one member | |
376 | if (iNofInputDataBlocks==0) iNofInputDataBlocks=1; | |
377 | AliHLTComponentBlockData init; | |
378 | memset(&init, 0, sizeof(AliHLTComponentBlockData)); | |
379 | fBlockDataArray.resize(iNofInputDataBlocks, init); | |
380 | ||
381 | // allocate the data buffer, which controls the output buffer and subscriptions | |
382 | if (iResult>=0) { | |
383 | fpDataBuffer=new AliHLTDataBuffer; | |
384 | if (fpDataBuffer!=NULL) { | |
dba03d72 | 385 | fpDataBuffer->SetLocalLoggingLevel(GetLocalLoggingLevel()); |
7a436c89 | 386 | HLTDebug("created data buffer %p for task %s (%p)", fpDataBuffer, GetName(), this); |
387 | TObjLink* lnk=fListTargets.FirstLink(); | |
388 | while (lnk && iResult>=0) { | |
389 | AliHLTTask* pTgtTask=(AliHLTTask*)lnk->GetObject(); | |
390 | if (pTgtTask) { | |
391 | if ((iResult=fpDataBuffer->SetConsumer(pTgtTask->GetComponent()))>=0) { | |
392 | } | |
393 | } else { | |
394 | break; | |
395 | iResult=-EFAULT; | |
396 | } | |
397 | lnk=lnk->Next(); | |
398 | } | |
399 | } else { | |
400 | HLTFatal("can not create data buffer object, memory allocation failed"); | |
401 | iResult=-ENOMEM; | |
402 | } | |
403 | } | |
404 | } | |
405 | } else { | |
406 | HLTError("task %s (%p) does not have a component", GetName(), this); | |
407 | iResult=-EFAULT; | |
408 | } | |
409 | return iResult; | |
410 | } | |
411 | ||
412 | int AliHLTTask::EndRun() | |
413 | { | |
414 | // see header file for function documentation | |
415 | int iResult=0; | |
416 | if (fBlockDataArray.size()>0) { | |
417 | fBlockDataArray.resize(0); | |
418 | } else { | |
419 | HLTWarning("task %s (%p) doesn't seem to be in running mode", GetName(), this); | |
420 | } | |
421 | if (fpDataBuffer) { | |
422 | AliHLTDataBuffer* pBuffer=fpDataBuffer; | |
423 | fpDataBuffer=NULL; | |
424 | delete pBuffer; | |
425 | } | |
426 | return iResult; | |
427 | } | |
428 | ||
429 | int AliHLTTask::ProcessTask(Int_t eventNo) | |
430 | { | |
431 | // see header file for function documentation | |
432 | int iResult=0; | |
433 | AliHLTComponent* pComponent=GetComponent(); | |
434 | if (pComponent && fpDataBuffer) { | |
435 | HLTDebug("Processing task %s (%p) fpDataBuffer %p", GetName(), this, fpDataBuffer); | |
436 | fpDataBuffer->Reset(); | |
437 | int iSourceDataBlock=0; | |
438 | int iInputDataVolume=0; | |
439 | ||
440 | AliHLTTask* pSrcTask=NULL; | |
441 | TList subscribedTaskList; | |
442 | TObjLink* lnk=fListDependencies.FirstLink(); | |
443 | ||
444 | // subscribe to all source tasks | |
445 | while (lnk && iResult>=0) { | |
446 | pSrcTask=(AliHLTTask*)lnk->GetObject(); | |
447 | if (pSrcTask) { | |
448 | int iMatchingDB=pSrcTask->GetNofMatchingDataBlocks(this); | |
449 | if (iMatchingDB>=0 && static_cast<unsigned int>(iMatchingDB)>fBlockDataArray.size()-iSourceDataBlock) { | |
450 | AliHLTComponentBlockData init; | |
451 | memset(&init, 0, sizeof(AliHLTComponentBlockData)); | |
452 | fBlockDataArray.resize(iSourceDataBlock+iMatchingDB, init); | |
453 | } else { | |
454 | if (iMatchingDB<0) { | |
455 | HLTError("task %s (%p): error getting no of matching data blocks from task %s (%p), error %d", GetName(), this, pSrcTask->GetName(), pSrcTask, iMatchingDB); | |
456 | iResult=iMatchingDB; | |
457 | break; | |
458 | } else if (iMatchingDB==0) { | |
459 | HLTDebug("source task %s (%p) does not provide any matching data type for task %s (%p)", pSrcTask->GetName(), pSrcTask, GetName(), this); | |
460 | } | |
461 | } | |
462 | if ((iResult=pSrcTask->Subscribe(this, &fBlockDataArray[iSourceDataBlock],fBlockDataArray.size()-iSourceDataBlock))>=0) { | |
463 | for (int i=0; i<iResult; i++) { | |
464 | iInputDataVolume+=fBlockDataArray[i+iSourceDataBlock].fSize; | |
465 | // put the source task as many times into the list as it provides data blocks | |
466 | // makes the bookkeeping for the data release easier | |
467 | subscribedTaskList.Add(pSrcTask); | |
468 | } | |
469 | HLTDebug("Task %s (%p) successfully subscribed to %d data block(s) of task %s (%p)", GetName(), this, iResult, pSrcTask->GetName(), pSrcTask); | |
470 | iSourceDataBlock+=iResult; | |
471 | iResult=0; | |
472 | } else { | |
473 | HLTError("Task %s (%p): subscription to task %s (%p) failed with error %d", GetName(), this, pSrcTask->GetName(), pSrcTask, iResult); | |
474 | iResult=-EFAULT; | |
475 | } | |
476 | } else { | |
477 | HLTFatal("fatal internal error in ROOT list handling"); | |
478 | iResult=-EFAULT; | |
479 | } | |
480 | lnk=lnk->Next(); | |
481 | } | |
482 | ||
483 | // process the event | |
484 | int iNofTrial=0; // repeat processing if component returns -ENOSPC | |
485 | AliHLTUInt32_t size=0; | |
486 | if (iResult>=0) { | |
487 | do { | |
488 | long unsigned int iConstBase=0; | |
489 | double fInputMultiplier=0; | |
490 | if (pComponent->GetComponentType()!=AliHLTComponent::kSink) | |
491 | pComponent->GetOutputDataSize(iConstBase, fInputMultiplier); | |
492 | if (fInputMultiplier<0) { | |
493 | HLTWarning("ignoring negative input multiplier"); | |
494 | fInputMultiplier=0; | |
495 | } | |
496 | long unsigned int iOutputDataSize=int(fInputMultiplier*iInputDataVolume) + iConstBase; | |
497 | //HLTDebug("task %s: reqired output size %d", GetName(), iOutputDataSize); | |
498 | if (iNofTrial>0) { | |
499 | // dont process again if the buffer size is the same | |
500 | if (size==iOutputDataSize) break; | |
501 | HLTInfo("processing task %s again with buffer size %d", GetName(), iOutputDataSize); | |
502 | } | |
503 | AliHLTUInt8_t* pTgtBuffer=NULL; | |
504 | if (iOutputDataSize>0) pTgtBuffer=fpDataBuffer->GetTargetBuffer(iOutputDataSize); | |
505 | //HLTDebug("provided raw buffer %p", pTgtBuffer); | |
506 | AliHLTComponentEventData evtData; | |
507 | AliHLTComponent::FillEventData(evtData); | |
508 | evtData.fEventID=(AliHLTEventID_t)eventNo; | |
509 | evtData.fBlockCnt=iSourceDataBlock; | |
510 | AliHLTComponentTriggerData trigData; | |
511 | size=iOutputDataSize; | |
512 | AliHLTUInt32_t outputBlockCnt=0; | |
513 | AliHLTComponentBlockData* outputBlocks=NULL; | |
514 | AliHLTComponentEventDoneData* edd; | |
515 | if (pTgtBuffer!=NULL || iOutputDataSize==0) { | |
516 | iResult=pComponent->ProcessEvent(evtData, &fBlockDataArray[0], trigData, pTgtBuffer, size, outputBlockCnt, outputBlocks, edd); | |
517 | HLTDebug("task %s: component %s ProcessEvent finnished (%d): size=%d blocks=%d", GetName(), pComponent->GetComponentID(), iResult, size, outputBlockCnt); | |
518 | if (iResult>=0 && pTgtBuffer && outputBlocks) { | |
519 | iResult=fpDataBuffer->SetSegments(pTgtBuffer, outputBlocks, outputBlockCnt); | |
520 | delete [] outputBlocks; outputBlocks=NULL; outputBlockCnt=0; | |
521 | } else { | |
522 | fpDataBuffer->Reset(); | |
523 | } | |
524 | } else { | |
525 | HLTError("task %s: no target buffer available", GetName()); | |
526 | iResult=-EFAULT; | |
527 | } | |
528 | } while (iResult==-ENOSPC && iNofTrial++<1); | |
529 | } | |
530 | ||
531 | // now release all buffers which we have subscribed to | |
532 | iSourceDataBlock=0; | |
533 | lnk=subscribedTaskList.FirstLink(); | |
534 | while (lnk) { | |
535 | pSrcTask=(AliHLTTask*)lnk->GetObject(); | |
536 | if (pSrcTask) { | |
537 | int iTempRes=0; | |
538 | if ((iTempRes=pSrcTask->Release(&fBlockDataArray[iSourceDataBlock], this))>=0) { | |
539 | HLTDebug("Task %s (%p) successfully released segment of task %s (%p)", GetName(), this, pSrcTask->GetName(), pSrcTask); | |
540 | } else { | |
541 | HLTError("Task %s (%p): realease of task %s (%p) failed with error %d", GetName(), this, pSrcTask->GetName(), pSrcTask, iTempRes); | |
542 | } | |
543 | } else { | |
544 | HLTFatal("task %s (%p): internal error in ROOT list handling", GetName(), this); | |
545 | if (iResult>=0) iResult=-EFAULT; | |
546 | } | |
547 | subscribedTaskList.Remove(lnk); | |
548 | lnk=subscribedTaskList.FirstLink(); | |
549 | iSourceDataBlock++; | |
550 | } | |
551 | if (subscribedTaskList.GetSize()>0) { | |
552 | HLTError("task %s (%p): could not release all data buffers", GetName(), this); | |
553 | } | |
554 | } else { | |
555 | HLTError("task %s (%p): internal failure (not initialized component %p, data buffer %p)", GetName(), this, fpComponent, fpDataBuffer); | |
556 | iResult=-EFAULT; | |
557 | } | |
558 | return iResult; | |
559 | } | |
560 | ||
561 | int AliHLTTask::GetNofMatchingDataBlocks(const AliHLTTask* pConsumerTask) const | |
562 | { | |
563 | // see header file for function documentation | |
564 | int iResult=0; | |
565 | if (pConsumerTask) { | |
566 | if (fpDataBuffer) { | |
567 | iResult=fpDataBuffer->FindMatchingDataBlocks(pConsumerTask->GetComponent(), NULL); | |
568 | } else { | |
569 | HLTFatal("internal data buffer missing"); | |
570 | iResult=-EFAULT; | |
571 | } | |
572 | } else { | |
573 | iResult=-EINVAL; | |
574 | } | |
575 | return iResult; | |
576 | } | |
577 | ||
578 | int AliHLTTask::GetNofMatchingDataTypes(const AliHLTTask* pConsumerTask) const | |
579 | { | |
580 | // see header file for function documentation | |
581 | int iResult=0; | |
582 | if (pConsumerTask) { | |
583 | AliHLTComponent* pComponent=GetComponent(); | |
584 | if (!pComponent) { | |
585 | // init ? | |
586 | HLTError("component not initialized"); | |
587 | iResult=-EFAULT; | |
588 | } | |
589 | if (pComponent) { | |
590 | iResult=pComponent->FindMatchingDataTypes(pConsumerTask->GetComponent(), NULL); | |
591 | } else { | |
592 | HLTFatal("task initialization failed"); | |
593 | iResult=-EFAULT; | |
594 | } | |
595 | } else { | |
596 | iResult=-EINVAL; | |
597 | } | |
598 | return iResult; | |
599 | } | |
600 | ||
601 | int AliHLTTask::Subscribe(const AliHLTTask* pConsumerTask, AliHLTComponentBlockData* pBlockDesc, int iArraySize) | |
602 | { | |
603 | // see header file for function documentation | |
604 | int iResult=0; | |
605 | if (pConsumerTask) { | |
606 | if (fpDataBuffer) { | |
607 | iResult=fpDataBuffer->Subscribe(pConsumerTask->GetComponent(), pBlockDesc, iArraySize); | |
608 | } else { | |
609 | HLTFatal("internal data buffer missing"); | |
610 | iResult=-EFAULT; | |
611 | } | |
612 | } else { | |
613 | iResult=-EINVAL; | |
614 | } | |
615 | return iResult; | |
616 | } | |
617 | ||
618 | int AliHLTTask::Release(AliHLTComponentBlockData* pBlockDesc, const AliHLTTask* pConsumerTask) | |
619 | { | |
620 | // see header file for function documentation | |
621 | int iResult=0; | |
622 | if (pConsumerTask && pBlockDesc) { | |
623 | if (fpDataBuffer) { | |
624 | iResult=fpDataBuffer->Release(pBlockDesc, pConsumerTask->GetComponent()); | |
625 | } else { | |
626 | HLTFatal("internal data buffer missing"); | |
627 | iResult=-EFAULT; | |
628 | } | |
629 | } else { | |
630 | iResult=-EINVAL; | |
631 | } | |
632 | return iResult; | |
633 | } | |
634 | ||
635 | void AliHLTTask::PrintStatus() | |
636 | { | |
637 | // see header file for function documentation | |
638 | HLTLogKeyword("task properties"); | |
639 | AliHLTComponent* pComponent=GetComponent(); | |
640 | if (pComponent) { | |
641 | HLTMessage(" component: %s (%p)", pComponent->GetComponentID(), pComponent); | |
642 | } else { | |
643 | HLTMessage(" no component set!"); | |
644 | } | |
645 | if (fpConfiguration) { | |
646 | AliHLTConfiguration* pSrc=fpConfiguration->GetFirstSource(); | |
647 | while (pSrc) { | |
648 | const char* pQualifier="unresolved"; | |
649 | if (FindDependency(pSrc->GetName())) | |
650 | pQualifier="resolved"; | |
651 | HLTMessage(" source: %s (%s)", pSrc->GetName(), pQualifier); | |
652 | pSrc=fpConfiguration->GetNextSource(); | |
653 | } | |
654 | TObjLink* lnk = fListTargets.FirstLink(); | |
655 | while (lnk) { | |
656 | TObject *obj = lnk->GetObject(); | |
657 | HLTMessage(" target: %s", obj->GetName()); | |
658 | lnk = lnk->Next(); | |
659 | } | |
660 | } else { | |
661 | HLTMessage(" task \"%s\" not initialized", GetName()); | |
662 | } | |
663 | } |