/usr/include/root/TFilePrefetch.h is in libroot-io-dev 5.34.30-0ubuntu8.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | // @(#)root/io:
// Author: Elvin Sindrilaru 19/05/2011
/*************************************************************************
* Copyright (C) 1995-2011, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#ifndef ROOT_TFilePrefetch
#define ROOT_TFilePrefetch
//////////////////////////////////////////////////////////////////////////
// //
// TFilePrefetch //
// //
// The prefetching mechanism uses two classes (TFilePrefetch and //
// TFPBlock) to prefetch in advance a block of tree entries. There is //
// a thread which takes care of actually transferring the blocks and //
// making them available to the main requesting thread. Therefore, //
// the time spent by the main thread waiting for the data before //
// processing considerably decreases. Besides the prefetching //
// mechanisms there is also a local caching option which can be //
// enabled by the user. Both capabilities are disabled by default //
// and must be explicitly enabled by the user. //
// //
//////////////////////////////////////////////////////////////////////////
#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; // reference to the file
TList *fPendingBlocks; // list of pending blocks to be read
TList *fReadBlocks; // list of blocks read
TThread *fConsumer; // consumer thread
TMutex *fMutexPendingList; // mutex for the pending list
TMutex *fMutexReadList; // mutex for the list of read blocks
TCondition *fNewBlockAdded; // signal the addition of a new pending block
TCondition *fReadBlockAdded; // signal the addition of a new red block
TSemaphore *fSemMasterWorker; // semaphore used to kill the consumer thread
TSemaphore *fSemWorkerMaster; // semaphore used to notify the master that worker is killed
TSemaphore *fSemChangeFile; // semaphore used when changin a file in TChain
TString fPathCache; // path to the cache directory
TStopwatch fWaitTime; // time wating to prefetch a buffer (in usec)
Bool_t fThreadJoined; // mark if async thread was joined
static TThread::VoidRtnFunc_t ThreadProc(void*); //create a joinable worker thread
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 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*);
TCondition* GetCondNewBlock() const { return fNewBlockAdded; };
void WaitFinishPrefetch();
ClassDef(TFilePrefetch, 0); // File block prefetcher
};
#endif
|