inline TInt DMemSamplerImpl::ProcessLibraries()
    {
    LOGTEXT("ProcessLibraries - entry");
    if(iNewLibraryCount > 0)
        {
        if(this->iLibrariesProcessing == EStartingToProcess)
            {
            // this is the first sample, encode a code for names
            this->iLibrariesProcessing = EProcessingNames;
            return EncodeNameCode();
            }

        if(iTotalMemoryNameOk == false)
            {
            return EncodeTotalMemoryName();
            }
        
        // there are new library names to report
        iNewLibraryCount--;
        DLibrary* l = this->libraryNamesToReport[iNewLibraryCount];
        return EncodeChunkName(*l);
        
        }
    else if(iLibraryCount > 0)
        {
        if(this->iLibrariesProcessing == EProcessingNames || this->iLibrariesProcessing == EStartingToProcess)
            {
            // this is the first data sample, encode a code for data
            this->iLibrariesProcessing = EProcessingData;
            return EncodeDataCode();
            }
        
        if(this->iTotalMemoryOk == false)
            {
            return EncodeTotalMemory(); 
            }

        // there are no new libraries to report
        // thus generate the real report
        iLibraryCount--;
        DLibrary* l = this->librariesToSample[iLibraryCount];
        return EncodeChunkData(*l);
        }
    else
        {
        // everything is processed
        LOGSTRING2(" Libraries processed! Library count = %d", iLibraryCount);

        this->iLibrariesGathered = true;
        Kern::Printf("MemSamplerImpl::ProcessLibraries() - libraries gathered! Time: %d",iCount);

        return 0;
        }
    }
inline TInt DMemSamplerImpl::ProcessChunks()
    {
    if(iNewChunkCount > 0)
        {
        if(this->iChunksProcessing == EStartingToProcess)
            {
            // this is the first sample, encode a code for names
            this->iChunksProcessing = EProcessingNames;
            return EncodeNameCode();
            }

        if(iTotalMemoryNameOk == false)
            {
            return EncodeTotalMemoryName();
            }
        
        // there are new chunk names to report
        iNewChunkCount--;
        DChunk* c = this->heapChunkNamesToReport[iNewChunkCount];
        return EncodeChunkName(*c);
        
        }
    else if(iChunkCount > 0)
        {
        if(this->iChunksProcessing == EProcessingNames || this->iChunksProcessing == EStartingToProcess)
            {
            // this is the first data sample, encode a code for data
            this->iChunksProcessing = EProcessingData;
            return EncodeDataCode();
            }
        
        if(this->iTotalMemoryOk == false)
            {
            return EncodeTotalMemory();	
            }

        // there are no new chunks to report
        // thus generate the real report
        iChunkCount--;
        DChunk* c = this->heapChunksToSample[iChunkCount];
        return EncodeChunkData(*c);
        }
    else
        {
        // everything is processed
        LOGSTRING2(" Chunks processed! Chunk count = %d", iChunkCount);
#ifdef MEM_EVENT_HANDLER
        this->iChunksGathered = true;
        Kern::Printf("MemSamplerImpl::ProcessChunks() - chunks gathered! Time: %d",iCount);
#endif
        return 0;
        }
    }
inline TInt DPriSamplerImpl::ProcessChunks()
    {
	/*
	 *
	 *	EKA-2 implementation of PRI trace
	 *
	 */

	if(iNewThreadCount > 0)
	    {
		if(this->iProcessing == EStartingToProcess)
		    {
			// this is the first sample, encode a code for names
			this->iProcessing = EProcessingNames;
			return EncodeNameCode();
            }

		// there are new thread names to report
		iNewThreadCount--;
		DThread* t = this->threadNamesToReport[iNewThreadCount];
		return EncodeChunkName(*t);
        }
	else if(iThreadCount > 0)
	    {
		if(this->iProcessing == EProcessingNames || this->iProcessing == EStartingToProcess)
		    {
			// this is the first data sample, encode a code for data
			this->iProcessing = EProcessingData;
			return EncodeDataCode();
            }

		// there are no new chunks to report
		// thus generate the real report
		iThreadCount--;
		DThread* t = this->threadsToSample[iThreadCount];
		LOGSTRING2("PriSamplerImpl::ProcessChunks - starting to process thread 0x%x",t);
		return EncodeChunkData(*t);
        }
	else
	    {
		// everything is processed
		return 0;
        }
    }