3 /**************************************************************************
4 * This file is property of and copyright by the ALICE HLT Project *
5 * ALICE Experiment at CERN, All rights reserved. *
7 * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 * for The ALICE HLT Project. *
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 **************************************************************************/
19 /** @file AliHLTDataBuffer.cxx
20 @author Matthias Richter
22 @brief Handling of Data Buffers for HLT components.
25 // see header file for class documentation
27 // refer to README to build package
29 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
35 #include "AliHLTDataBuffer.h"
36 #include "AliHLTConsumerDescriptor.h"
37 #include "AliHLTComponent.h"
38 #include "AliHLTTask.h"
42 //#include "AliHLTSystem.h"
44 typedef vector<AliHLTDataBuffer::AliHLTDataSegment> AliHLTDataSegmentList;
45 typedef vector<AliHLTDataBuffer::AliHLTRawBuffer*> AliHLTRawBufferPList;
47 /** ROOT macro for the implementation of ROOT specific class methods */
48 ClassImp(AliHLTDataBuffer)
50 AliHLTDataBuffer::AliHLTDataBuffer()
58 fForwardedSegmentSources(),
61 // see header file for class documentation
63 // refer to README to build package
65 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
68 fActiveConsumers.empty();
69 fReleasedConsumers.empty();
73 int AliHLTDataBuffer::fgNofInstances=0;
74 AliHLTRawBufferPList AliHLTDataBuffer::fgFreeBuffers;
75 AliHLTRawBufferPList AliHLTDataBuffer::fgActiveBuffers;
76 AliHLTUInt32_t AliHLTDataBuffer::fgMargin=1024;
77 AliHLTLogging AliHLTDataBuffer::fgLogging;
78 const Int_t AliHLTDataBuffer::fgkSafetyPatternSize=16;
79 const char AliHLTDataBuffer::fgkSafetyPattern[]={0x28, 0x63, 0x29, 0x4d, 0x52, 0x49, 0x43, 0x48, 0x54, 0x45, 0x52, 0x20, 0x32, 0x30, 0x30, 0x37};
81 AliHLTDataBuffer::~AliHLTDataBuffer()
83 // see header file for function documentation
84 if (--fgNofInstances<=0) {
87 CleanupConsumerList();
90 int AliHLTDataBuffer::SetConsumer(AliHLTComponent* pConsumer)
92 // see header file for function documentation
95 if (FindConsumer(pConsumer)) {
96 HLTWarning("consumer %s (%p) already set to data buffer %p", pConsumer->GetComponentID(), pConsumer, this);
98 AliHLTConsumerDescriptor* pDesc=new AliHLTConsumerDescriptor(pConsumer);
100 fConsumers.push_back(pDesc);
101 HLTDebug("set consumer %s (%p) to data buffer %p", pConsumer->GetComponentID(), pConsumer, this);
103 HLTError("memory allocation failed");
107 HLTError("invalid parameter: consumer component (nil)");
113 int AliHLTDataBuffer::FindMatchingDataBlocks(const AliHLTComponent* pConsumer, AliHLTComponentDataTypeList* tgtList)
115 // see header file for function documentation
118 AliHLTDataSegmentList segments;
119 if ((iResult=FindMatchingDataSegments(pConsumer, segments))>=0) {
121 AliHLTDataSegmentList::iterator segment=segments.begin();
122 while (segment!=segments.end()) {
123 tgtList->push_back((*segment).fDataType);
127 iResult=segments.size();
135 int AliHLTDataBuffer::FindMatchingDataSegments(const AliHLTComponent* pConsumer, vector<AliHLTDataBuffer::AliHLTDataSegment>& tgtList)
137 // see header file for function documentation
140 // Matthias 26.09.2007 relax the restriction to matching data blocks
141 // all blocks are passed to the consumer, which is the policy also in
143 tgtList.assign(fSegments.begin(), fSegments.end());
145 // add all forwarded blocks
146 tgtList.insert(tgtList.begin(), fForwardedSegments.begin(), fForwardedSegments.end());
147 iResult=tgtList.size();
151 AliHLTComponentDataTypeList dtlist;
152 ((AliHLTComponent*)pConsumer)->GetInputDataTypes(dtlist);
153 AliHLTDataSegmentList::iterator segment=fSegments.begin();
154 while (segment!=fSegments.end()) {
155 AliHLTComponentDataTypeList::iterator type=dtlist.begin();
156 while (type!=dtlist.end()) {
157 if ((*segment).fDataType==(*type) ||
158 (*type)==kAliHLTAnyDataType) {
159 tgtList.push_back(*segment);
173 int AliHLTDataBuffer::Subscribe(const AliHLTComponent* pConsumer, AliHLTComponentBlockDataList& blockDescList)
175 // see header file for function documentation
179 AliHLTConsumerDescriptor* pDesc=FindConsumer(pConsumer, fConsumers);
181 AliHLTDataSegmentList tgtList;
182 // Matthias 26.07.2007 AliHLTSystem should behave the same way as PubSub
183 // so it does not matter if there are matching data types or not, unless
184 // we implement such a check in PubSub
185 if ((iResult=FindMatchingDataSegments(pConsumer, tgtList))>=0) {
186 AliHLTDataSegmentList::iterator segment=tgtList.begin();
187 while (segment!=tgtList.end()) {
188 // fill the block data descriptor
189 AliHLTComponentBlockData bd;
190 AliHLTComponent::FillBlockData(bd);
191 // This models the behavior of PubSub.
192 // For incoming data blocks, fOffset must be ignored by the
193 // processing component. It is set for bookkeeping in the framework.
194 // fPtr always points to the beginning of the data.
196 AliHLTUInt8_t* pTgt=*segment;
197 bd.fPtr=reinterpret_cast<void*>(pTgt);
198 bd.fSize=(*segment).fSegmentSize;
199 bd.fDataType=(*segment).fDataType;
200 bd.fSpecification=(*segment).fSpecification;
201 blockDescList.push_back(bd);
202 pDesc->SetActiveDataSegment(*segment);
203 HLTDebug("component %p (%s) subscribed to segment offset %d size %d data type %s %#x",
204 pConsumer, ((AliHLTComponent*)pConsumer)->GetComponentID(), bd.fOffset,
205 bd.fSize, (AliHLTComponent::DataType2Text(bd.fDataType)).c_str(),
209 // move this consumer to the active list
210 if (tgtList.size()==0) {
211 ChangeConsumerState(pDesc, fConsumers, fReleasedConsumers);
212 HLTDebug("no input data for component %p (%s) available", pConsumer, ((AliHLTComponent*)pConsumer)->GetComponentID());
213 } else if (ChangeConsumerState(pDesc, fConsumers, fActiveConsumers)>=0) {
214 HLTDebug("component %p (%s) subscribed to data buffer %p", pConsumer, ((AliHLTComponent*)pConsumer)->GetComponentID(), this);
216 // TODO: cleanup the consumer descriptor correctly
217 segment=tgtList.begin();
218 while (segment!=tgtList.end()) {
219 blockDescList.pop_back();
222 HLTError("can not activate consumer %p for data buffer %p", pConsumer, this);
226 HLTError("unresolved data segment(s) for component %p (%s)", pConsumer, ((AliHLTComponent*)pConsumer)->GetComponentID());
230 HLTError("component %p is not a data consumer of data buffer %s", pConsumer, this);
234 // Matthias 26.07.2007 until now, data had to be present for successful subscription
235 // in order to be consistent with the PubSub framework, this restiction has been
237 //HLTError("data buffer %p is empty", this);
241 HLTError("invalid parameter");
247 int AliHLTDataBuffer::Release(AliHLTComponentBlockData* pBlockDesc,
248 const AliHLTComponent* pConsumer,
249 const AliHLTTask* pOwnerTask)
251 // see header file for function documentation
253 if (pBlockDesc && pConsumer) {
254 AliHLTConsumerDescriptor* pDesc=FindConsumer(pConsumer, fActiveConsumers);
256 if ((iResult=pDesc->CheckActiveDataSegment(AliHLTDataSegment(pBlockDesc->fPtr, pBlockDesc->fOffset, pBlockDesc->fSize)))!=1) {
257 HLTWarning("data segment missmatch, component %p has not subscribed to a segment with offset %#x and size %d", pConsumer, pBlockDesc->fOffset, pBlockDesc->fSize);
258 // TODO: appropriate error handling, but so far optional
261 pDesc->ReleaseActiveDataSegment(AliHLTDataSegment(pBlockDesc->fPtr, pBlockDesc->fOffset, pBlockDesc->fSize));
263 if (GetNofPendingConsumers()==0 && fForwardedSegments.size()>0) {
264 // last consumer, release forwarded segments
265 assert(fForwardedSegments.size()==fForwardedSegmentSources.size());
266 AliHLTDataSegmentList::iterator segment=fForwardedSegments.begin();
267 AliHLTTaskPList::iterator src=fForwardedSegmentSources.begin();
268 //HLTDebug("%p checking forwarded segments", this);
269 for (; segment!=fForwardedSegments.end(); segment++, src++) {
270 //HLTDebug("segment ptr=%p offset=%d size=%d\n"
271 // "block ptr=%p offset=%d size=%d", (*segment).fPtr, (*segment).fSegmentOffset, (*segment).fSegmentSize, pBlockDesc->fPtr, pBlockDesc->fOffset, pBlockDesc->fSize);
272 if ((*segment)==AliHLTDataSegment(pBlockDesc->fPtr, pBlockDesc->fOffset, pBlockDesc->fSize)) {
273 //HLTDebug("release segment of task %p", *src);
274 assert((*src)!=NULL);
276 if ((*src)->Release(pBlockDesc, pOwnerTask)>=0) {
277 HLTDebug("task %s (%p) released forwarded segment %p size %d of task %s (%p)",
278 pOwnerTask->GetName(), pOwnerTask, (*segment).GetPtr(), (*segment).GetSize(),
279 (*src)->GetName(), *src);
281 HLTError("task %s (%p) failed releasing forwarded segment %p size %d of task %s (%p)",
282 pOwnerTask->GetName(), pOwnerTask, (*segment).GetPtr(), (*segment).GetSize(),
283 (*src)->GetName(), *src);
286 fForwardedSegments.erase(segment);
287 fForwardedSegmentSources.erase(src);
292 pBlockDesc->fOffset=0;
293 pBlockDesc->fPtr=NULL;
295 if (pDesc->GetNofActiveSegments()==0) {
296 if ((iResult=ChangeConsumerState(pDesc, fActiveConsumers, fReleasedConsumers))>=0) {
297 if (GetNofActiveConsumers()==0 && GetNofPendingConsumers()==0) {
298 // this is the last consumer, reset the consumer list and release the raw buffer
302 HLTError("can not deactivate consumer %p for data buffer %p", pConsumer, this);
307 HLTWarning("component %p has currently not subscribed to the data buffer %p", pConsumer, this);
311 HLTError("inavalid parameter: pBlockDesc=%p pConsumer=%p", pBlockDesc, pConsumer);
317 int AliHLTDataBuffer::Forward(AliHLTTask* pSrcTask, AliHLTComponentBlockData* pBlockDesc)
319 // see header file for function documentation
320 if (pSrcTask==NULL || pBlockDesc==NULL) return -EINVAL;
321 assert(fForwardedSegments.size()==fForwardedSegmentSources.size());
322 if (fForwardedSegments.size()!=fForwardedSegmentSources.size()) return -EFAULT;
323 fForwardedSegmentSources.push_back(pSrcTask);
324 fForwardedSegments.push_back(AliHLTDataSegment(pBlockDesc->fPtr, pBlockDesc->fOffset, pBlockDesc->fSize, pBlockDesc->fDataType, pBlockDesc->fSpecification));
328 AliHLTUInt8_t* AliHLTDataBuffer::GetTargetBuffer(int iMinSize)
330 // see header file for function documentation
331 AliHLTUInt8_t* pTargetBuffer=NULL;
332 if (fpBuffer!=NULL) {
333 HLTWarning("data buffer not properly reset, possible memory leak\n");
335 fpBuffer=CreateRawBuffer(iMinSize);
337 pTargetBuffer=*fpBuffer;
339 HLTError("can not create raw buffer");
341 return pTargetBuffer;
344 int AliHLTDataBuffer::SetSegments(AliHLTUInt8_t* pTgt, AliHLTComponentBlockData* arrayBlockData, int iSize)
346 // see header file for function documentation
348 if (pTgt && arrayBlockData && iSize>=0) {
350 if (*fpBuffer==pTgt) {
351 AliHLTDataBuffer::AliHLTDataSegment segment;
352 for (int i=0; i<iSize; i++) {
353 // This function has to model the behavior of PubSub
354 // For output blocks only the fOffset value is used, this must be the offset
355 // relative to the output pointer. fPtr must be either NULL or the output
356 // pointer. In either case it is 'ignored' and set to the beginning of the
358 if (arrayBlockData[i].fPtr==NULL ||
359 arrayBlockData[i].fPtr==*fpBuffer) {
360 arrayBlockData[i].fPtr=*fpBuffer;
361 if (arrayBlockData[i].fOffset+arrayBlockData[i].fSize<=fpBuffer->GetUsedSize()) {
362 segment.fSegmentOffset=arrayBlockData[i].fOffset;
363 segment.fPtr=(AliHLTUInt8_t*)arrayBlockData[i].fPtr;
364 segment.fSegmentSize=arrayBlockData[i].fSize;
365 segment.fDataType=arrayBlockData[i].fDataType;
366 segment.fSpecification=arrayBlockData[i].fSpecification;
367 fSegments.push_back(segment);
368 HLTDebug("set segment %s with size %d at offset %d", AliHLTComponent::DataType2Text(segment.fDataType).data(), segment.fSegmentSize, segment.fSegmentOffset);
370 HLTError("block data specification %#d (%s) exceeds size of data buffer", i, AliHLTComponent::DataType2Text(arrayBlockData[i].fDataType).data());
371 HLTError("block offset=%d, block size=%d, buffer size=%d", arrayBlockData[i].fOffset, arrayBlockData[i].fSize, fpBuffer->GetUsedSize());
375 HLTError("invalid pointer (%p) in block data specification (buffer %p size %d)."
376 "please note: for output blocks only the fOffset value is valid and must "
377 "be relative to the output buffer", arrayBlockData[i].fPtr, fpBuffer->GetPointer(), fpBuffer->GetUsedSize());
382 HLTError("this data buffer (%p) does not match the internal data buffer %p of raw buffer %p", pTgt, fpBuffer->GetPointer(), fpBuffer);
386 HLTFatal("internal data structur missmatch");
390 HLTError("invalid parameter: pTgtBuffer=%p arrayBlockData=%p", pTgt, arrayBlockData);
396 int AliHLTDataBuffer::IsEmpty()
398 // see header file for function documentation
399 int iResult=fpBuffer==NULL || GetNofSegments()==0;
403 int AliHLTDataBuffer::GetNofSegments()
405 // see header file for function documentation
406 int iResult=fSegments.size();
410 int AliHLTDataBuffer::GetNofConsumers()
412 // see header file for function documentation
413 int iResult=fConsumers.size() + GetNofActiveConsumers() + fReleasedConsumers.size();
417 int AliHLTDataBuffer::GetNofPendingConsumers()
419 // see header file for function documentation
420 int iResult=fConsumers.size();
424 int AliHLTDataBuffer::GetNofActiveConsumers()
426 // see header file for function documentation
427 int iResult=fActiveConsumers.size();
431 AliHLTDataBuffer::AliHLTRawBuffer* AliHLTDataBuffer::CreateRawBuffer(AliHLTUInt32_t size)
433 // see header file for function documentation
434 AliHLTRawBuffer* pRawBuffer=NULL;
435 unsigned int reqSize=size+fgkSafetyPatternSize;
436 AliHLTRawBufferPList::iterator buffer=fgFreeBuffers.begin();
437 while (buffer!=fgFreeBuffers.end() && pRawBuffer==NULL) {
438 if ((*buffer)->CheckSize(reqSize)) {
439 // assign this element
441 pRawBuffer->UseBuffer(size);
442 fgFreeBuffers.erase(buffer);
443 fgLogging.Logging(kHLTLogDebug, "AliHLTDataBuffer::CreateRawBuffer", "data buffer handling", "raw buffer container %p provided for request of %d bytes (total %d available in buffer %p)", pRawBuffer, size, pRawBuffer->GetTotalSize(), pRawBuffer->GetPointer());
444 fgActiveBuffers.push_back(pRawBuffer);
449 if (pRawBuffer==NULL) {
450 // no buffer found, create a new one
451 pRawBuffer=new AliHLTRawBuffer(reqSize);
453 if (pRawBuffer->GetPointer()) {
454 pRawBuffer->UseBuffer(size);
455 fgActiveBuffers.push_back(pRawBuffer);
456 fgLogging.Logging(kHLTLogDebug, "AliHLTDataBuffer::CreateRawBuffer", "data buffer handling", "new raw buffer %p of size %d created (container %p)", pRawBuffer->GetPointer(), pRawBuffer->GetTotalSize(), pRawBuffer);
460 fgLogging.Logging(kHLTLogError, "AliHLTDataBuffer::CreateRawBuffer", "data buffer handling", "memory allocation failed");
463 fgLogging.Logging(kHLTLogError, "AliHLTDataBuffer::CreateRawBuffer", "data buffer handling", "memory allocation failed");
466 if (pRawBuffer!=NULL && fgkSafetyPatternSize>0) {
467 //fgLogging.Logging(kHLTLogDebug, "AliHLTDataBuffer::CreateRawBuffer", "data buffer handling", "writing safety pattern to %p offset %d", (*buffer)->GetPointer(), (*buffer)->GetUsedSize());
468 pRawBuffer->WritePattern(fgkSafetyPattern, fgkSafetyPatternSize);
473 int AliHLTDataBuffer::ReleaseRawBuffer(AliHLTRawBuffer* pBuffer)
475 // see header file for function documentation
478 AliHLTRawBufferPList::iterator buffer=fgActiveBuffers.begin();
479 while (buffer!=fgActiveBuffers.end() && (*buffer)!=pBuffer) {
482 if (buffer!=fgActiveBuffers.end()) {
483 if (fgkSafetyPatternSize>0) {
484 //fgLogging.Logging(kHLTLogDebug, "AliHLTDataBuffer::ReleaseRawBuffer", "data buffer handling", "comparing safety pattern at %p offset %d", (*buffer)->GetPointer(), reinterpret_cast<AliHLTUInt32_t>(*buffer));
485 if ((*buffer)->CheckPattern(fgkSafetyPattern, fgkSafetyPatternSize)) {
486 fgLogging.Logging(kHLTLogFatal, "AliHLTDataBuffer::ReleaseRawBuffer", "data buffer handling", "component has written beyond end of data buffer %p size %d", (*buffer)->GetPointer(), (*buffer)->GetUsedSize());
490 fgFreeBuffers.push_back(*buffer);
491 fgActiveBuffers.erase(buffer);
493 fgLogging.Logging(kHLTLogWarning, "AliHLTDataBuffer::ReleaseRawBuffer", "data buffer handling", "can not find raw buffer container %p in the list of active containers", pBuffer);
497 fgLogging.Logging(kHLTLogError, "AliHLTDataBuffer::ReleaseRawBuffer", "data buffer handling", "invalid parameter");
504 int AliHLTDataBuffer::DeleteRawBuffers()
506 // see header file for function documentation
509 // int iCount=fgFreeBuffers.size()+fgActiveBuffers.size();
510 AliHLTRawBufferPList::iterator buffer;;
511 while ((buffer=fgFreeBuffers.begin())!=fgFreeBuffers.end()) {
512 // iTotalSize+=(*buffer)->GetTotalSize();
514 fgFreeBuffers.erase(buffer);
516 while ((buffer=fgActiveBuffers.begin())!=fgActiveBuffers.end()) {
517 // iTotalSize+=(*buffer)->GetTotalSize();
518 fgLogging.Logging(kHLTLogWarning, "AliHLTDataBuffer::ReleaseRawBuffer", "data buffer handling", "request to delete active raw buffer container (raw buffer %p, size %d)", (*buffer)->GetPointer(), (*buffer)->GetTotalSize());
520 fgActiveBuffers.erase(buffer);
522 // fgLogging.Logging(kHLTLogInfo, "AliHLTDataBuffer::ReleaseRawBuffer", "data buffer handling", "Total memory allocation: %d byte in %d buffers", iTotalSize, iCount);
526 AliHLTConsumerDescriptor* AliHLTDataBuffer::FindConsumer(const AliHLTComponent* pConsumer, AliHLTConsumerDescriptorPList &list) const
528 // see header file for function documentation
529 AliHLTConsumerDescriptor* pDesc=NULL;
530 AliHLTConsumerDescriptorPList::iterator desc=list.begin();
531 while (desc!=list.end() && pDesc==NULL) {
532 if ((pConsumer==NULL || (*desc)->GetComponent()==pConsumer)) {
540 int AliHLTDataBuffer::ResetDataBuffer()
542 // see header file for function documentation
544 AliHLTRawBuffer* pBuffer=fpBuffer;
547 // cleanup forwarded segment lists
548 assert(fForwardedSegments.size()==0);
549 fForwardedSegments.clear();
550 fForwardedSegmentSources.clear();
552 // cleanup consumer states
553 AliHLTConsumerDescriptorPList::iterator desc;
554 // if (GetNofPendingConsumers()>0) {
555 // desc=fConsumers.begin();
556 // while (desc!=fConsumers.end()) {
557 // AliHLTComponent* pComp=(*desc)->GetComponent();
558 // HLTError("internal error: consumer %p (%s %p) did not get data from data buffer %p", *desc, pComp?pComp->GetComponentID():"", pComp, this);
562 desc=fReleasedConsumers.begin();
563 while (desc!=fReleasedConsumers.end()) {
564 AliHLTConsumerDescriptor* pDesc=*desc;
565 fReleasedConsumers.erase(desc);
566 desc=fReleasedConsumers.begin();
567 fConsumers.push_back(pDesc);
569 desc=fActiveConsumers.begin();
570 while (desc!=fActiveConsumers.end()) {
571 AliHLTConsumerDescriptor* pDesc=*desc;
572 HLTWarning("consumer %p was not released", pDesc);
573 fActiveConsumers.erase(desc);
574 desc=fActiveConsumers.begin();
575 fConsumers.push_back(pDesc);
579 AliHLTDataSegmentList::iterator segment=fSegments.begin();
580 while (segment!=fSegments.end()) {
581 fSegments.erase(segment);
582 segment=fSegments.begin();
585 // cleanup raw buffer
587 ReleaseRawBuffer(pBuffer);
592 int AliHLTDataBuffer::Reset()
594 // see header file for function documentation
595 return ResetDataBuffer();
598 // this is the version which works on lists of components instead of consumer descriptors
599 // int AliHLTDataBuffer::ChangeConsumerState(AliHLTComponent* pConsumer, AliHLTComponentPList &srcList, AliHLTComponentPList &tgtList)
603 // AliHLTComponentPList::iterator desc=srcList.begin();
604 // while (desc!=srcList.end()) {
605 // if ((*desc)==pConsumer) {
606 // srcList.erase(desc);
607 // tgtList.push_back(pConsumer);
612 // if (desc==srcList.end()) {
613 // HLTError("can not find consumer component %p in list", pConsumer);
617 // HLTError("invalid parameter");
623 int AliHLTDataBuffer::ChangeConsumerState(AliHLTConsumerDescriptor* pDesc, AliHLTConsumerDescriptorPList &srcList, AliHLTConsumerDescriptorPList &tgtList)
625 // see header file for function documentation
628 AliHLTConsumerDescriptorPList::iterator desc=srcList.begin();
629 while (desc!=srcList.end()) {
630 if ((*desc)==pDesc) {
632 tgtList.push_back(pDesc);
639 HLTError("can not find consumer descriptor %p in list", pDesc);
642 HLTError("invalid parameter");
648 int AliHLTDataBuffer::CleanupConsumerList()
650 // see header file for function documentation
653 AliHLTConsumerDescriptorPList::iterator desc=fConsumers.begin();
654 while (desc!=fConsumers.end()) {
656 fConsumers.erase(desc);
657 desc=fConsumers.begin();
662 int AliHLTDataBuffer::FindConsumer(AliHLTComponent* pConsumer, int bAllLists)
664 // see header file for function documentation
665 AliHLTConsumerDescriptorPList::iterator desc=fConsumers.begin();
666 while (desc!=fConsumers.end()) {
667 if ((*desc)->GetComponent()==pConsumer)
671 if (bAllLists==0) return 0;
673 desc=fActiveConsumers.begin();
674 while (desc!=fActiveConsumers.end()) {
675 if ((*desc)->GetComponent()==pConsumer)
679 desc=fReleasedConsumers.begin();
680 while (desc!=fReleasedConsumers.end()) {
681 if ((*desc)->GetComponent()==pConsumer)
688 AliHLTDataBuffer::AliHLTRawBuffer::AliHLTRawBuffer(AliHLTUInt32_t size)
692 fPtr(static_cast<AliHLTUInt8_t*>(malloc(size)))
694 // see header file for class documentation
696 // refer to README to build package
698 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
705 AliHLTDataBuffer::AliHLTRawBuffer::~AliHLTRawBuffer()
715 int AliHLTDataBuffer::AliHLTRawBuffer::operator==(void* ptr) const
717 // see header file for function documentation
718 return fPtr == static_cast<AliHLTUInt8_t*>(ptr);
721 int AliHLTDataBuffer::AliHLTRawBuffer::operator<=(void* ptr) const
723 // see header file for function documentation
724 int iResult=fPtr <= static_cast<AliHLTUInt8_t*>(ptr);
725 //printf("%p: %p <= %p (%d)\n", this, fPtr, ptr, iResult);
729 int AliHLTDataBuffer::AliHLTRawBuffer::operator>(void* ptr) const
731 // see header file for function documentation
732 int iResult=fPtr+fSize > static_cast<AliHLTUInt8_t*>(ptr);
733 //printf("%p: %p + %d > %p (%d)\n", this, fPtr, fSize, ptr, iResult);
737 int AliHLTDataBuffer::AliHLTRawBuffer::operator-(void* ptr) const
739 // see header file for function documentation
740 return static_cast<int>(static_cast<AliHLTUInt8_t*>(ptr)-fPtr);
743 AliHLTUInt8_t* AliHLTDataBuffer::AliHLTRawBuffer::UseBuffer(AliHLTUInt32_t size)
745 // see header file for function documentation
746 if (size>0 && fTotalSize>=size) {
753 int AliHLTDataBuffer::AliHLTRawBuffer::CheckSize(AliHLTUInt32_t size) const
755 // see header file for function documentation
756 return fTotalSize>=size && ((fTotalSize-size)<fgMargin);
759 int AliHLTDataBuffer::AliHLTRawBuffer::Reset()
761 // see header file for function documentation
766 int AliHLTDataBuffer::AliHLTRawBuffer::WritePattern(const char* pattern, int size)
768 // see header file for function documentation
770 if (pattern!=NULL && size>0) {
771 if (fSize+size<=fTotalSize) {
772 memcpy(((char*)fPtr)+fSize, pattern, size);
781 int AliHLTDataBuffer::AliHLTRawBuffer::CheckPattern(const char* pattern, int size) const
783 // see header file for function documentation
785 if (pattern!=NULL && size>0) {
786 if (fSize+size<=fTotalSize) {
787 iResult=memcmp(((char*)fPtr)+fSize, pattern, size)!=0;