#ifndef ROOT_TFilePrefetch
#define ROOT_TFilePrefetch
#ifndef ROOT_TFile
#include "TFile.h"
#endif
#ifndef ROOT_TThread
#include "TThread.h"
#endif
#ifndef ROOT_TFPBlock
#include "TFPBlock.h"
#endif
#ifndef ROOT_TCondition
#include "TCondition.h"
#endif
#ifndef ROOT_TSemaphore
#include "TSemaphore.h"
#endif
#ifndef ROOT_TMD5
#include "TMD5.h"
#endif
#ifndef ROOT_TObject
#include "TObject.h"
#endif
#ifndef ROOT_TString
#include "TString.h"
#endif
#ifndef ROOT_TObjString
#include "TObjString.h"
#endif
#ifndef ROOT_TMutex
#include "TMutex.h"
#endif
#ifndef ROOT_TObjArray
#include "TObjArray.h"
#endif
#ifndef ROOT_TStopwatch
#include "TStopwatch.h"
#endif
class TFilePrefetch : public TObject {
private:
TFile *fFile;
TList *fPendingBlocks;
TList *fReadBlocks;
TThread *fConsumer;
TMutex *fMutexPendingList;
TMutex *fMutexReadList;
TMutex *fMutexSynch;
TCondition *fNewBlockAdded;
TCondition *fReadBlockAdded;
TSemaphore *fSem;
TString fPathCache;
TStopwatch fWaitTime;
static TThread::VoidRtnFunc_t ThreadProc(void*);
public:
TFilePrefetch(TFile*);
virtual ~TFilePrefetch();
void ReadAsync(TFPBlock*, Bool_t&);
void ReadListOfBlocks();
void AddPendingBlock(TFPBlock*);
TFPBlock *GetPendingBlock();
void AddReadBlock(TFPBlock*);
Bool_t ReadBuffer(char*, Long64_t, Int_t);
void ReadBlock(Long64_t*, Int_t*, Int_t);
TFPBlock *CreateBlockObj(Long64_t*, Int_t*, Int_t);
TThread *GetThread() const;
Int_t ThreadStart();
Bool_t SetCache(const char*);
Bool_t CheckCachePath(const char*);
Bool_t CheckBlockInCache(char*&, TFPBlock*);
char *GetBlockFromCache(const char*, Int_t);
void SaveBlockInCache(TFPBlock*);
Int_t SumHex(const char*);
Bool_t BinarySearchReadList(TFPBlock*, Long64_t, Int_t, Int_t*);
Long64_t GetWaitTime();
void SetFile(TFile*);
TMutex* GetMutexSynch() const { return fMutexSynch; };
ClassDef(TFilePrefetch, 0);
};
#endif