12 #ifndef ROOT_TFilePrefetch
13 #define ROOT_TFilePrefetch
27 #include <condition_variable>
31 class TFilePrefetch :
public TObject {
35 TList *fPendingBlocks;
38 std::mutex fMutexPendingList;
39 std::mutex fMutexReadList;
40 std::condition_variable fNewBlockAdded;
41 std::condition_variable fReadBlockAdded;
42 TSemaphore *fSemChangeFile;
46 std::atomic<Bool_t> fPrefetchFinished;
48 static TThread::VoidRtnFunc_t ThreadProc(
void*);
51 TFilePrefetch(TFile*);
52 virtual ~TFilePrefetch();
54 void ReadAsync(TFPBlock*, Bool_t&);
55 void ReadListOfBlocks();
57 void AddPendingBlock(TFPBlock*);
58 TFPBlock *GetPendingBlock();
60 void AddReadBlock(TFPBlock*);
61 Bool_t ReadBuffer(
char*, Long64_t, Int_t);
62 void ReadBlock(Long64_t*, Int_t*, Int_t);
63 TFPBlock *CreateBlockObj(Long64_t*, Int_t*, Int_t);
65 TThread *GetThread()
const;
68 Bool_t SetCache(
const char*);
69 Bool_t CheckBlockInCache(
char*&, TFPBlock*);
70 char *GetBlockFromCache(
const char*, Int_t);
71 void SaveBlockInCache(TFPBlock*);
73 Int_t SumHex(
const char*);
74 Bool_t BinarySearchReadList(TFPBlock*, Long64_t, Int_t, Int_t*);
75 Long64_t GetWaitTime();
77 void SetFile(TFile* file, TFile::ECacheAction action = TFile::kDisconnect);
78 std::condition_variable &GetCondNewBlock() {
return fNewBlockAdded; };
79 void WaitFinishPrefetch();
80 Bool_t IsPrefetchFinished()
const {
return fPrefetchFinished; }
82 ClassDef(TFilePrefetch, 0);