67 mBlockNum = nBlockNum;
163 void GetBlockSpan(
long long nOffset,
int nBytes,
int *pnFirst,
int *pnCount,
int *pnBlockSize);
260 static bool Read(
int nSector,
int nCount,
void *pBuffer);
263 const std::vector<std::unique_ptr<Block>> &
GetBlocks()
const {
268 std::list<BlockRequest> mRequests;
269 std::vector<std::unique_ptr<Block>>
mBlocks;
271 int mSectorsPerBlock;
BlockMgr TheBlockMgr
The disc cache.
Read-only file of the main archive, read through the disc cache.
Definition arkfile.h:11
Cache of disc blocks that ArkFile reads go through.
Definition blockmgr.h:142
void GetBlockSpan(long long nOffset, int nBytes, int *pnFirst, int *pnCount, int *pnBlockSize)
Report the blocks a run of bytes of the disc covers.
void KillBlockRequests(ArkFile *pFile)
Drop every task of a file, and every request left with no task unless its block is loading.
static bool ReadDone()
Report whether the read of the drive finished.
void AddRequest(const AsyncTask &task)
Queue a task, joining the request for its block or inserting a new one in block order.
Block * FindBlock(int nBlock)
Find the block holding a block of the disc.
std::vector< Block * > mBlocks
Definition BlockMgr.h:91
int SectorToByte(int nSector)
Report the byte of the disc a sector starts at.
char * GetBlockData(int nBlock)
Report the data of a loaded block and mark the block used.
Block * FindOldestBlock()
Find the block used longest ago.
const std::vector< std::unique_ptr< Block > > & GetBlocks() const
Definition blockmgr.h:263
void Init()
Build the blocks of the cache.
void Poll()
Finish the block that loaded, completing its tasks, and start loading the next request.
static bool Read(int nSector, int nCount, void *pBuffer)
Start reading sectors of the disc.
static int ReadError()
Report the error of the last read of the drive.
One block buffer of the disc cache.
Definition blockmgr.h:15
int GetBlockNum() const
Definition blockmgr.h:57
void Touch()
Mark the block used now.
Block()
Take the next buffer and mark the block used now.
static int NextBuffer()
Report the index of the next buffer a block takes, and advance it.
int GetTimestamp() const
Definition blockmgr.h:71
static int CurrentTime()
Report the latest use mark Touch() handed out.
void SetBlockNum(int nBlockNum)
Set the block of the disc the buffer stores.
Definition blockmgr.h:66
char * GetBuffer() const
Definition blockmgr.h:52
One part of an ArkFile read, which a single block of the disc satisfies.
Definition blockmgr.h:86
int mBlock
Definition blockmgr.h:109
int mStart
Definition blockmgr.h:110
int mEnd
Definition blockmgr.h:111
AsyncTask(ArkFile *pFile, char *pBuffer, int nBlock, int nStart, int nEnd)
Describe the part of a read.
char * mBuffer
Definition blockmgr.h:112
bool TryComplete()
Copy the bytes from the cache when their block is loaded, and report them to the file.
ArkFile * mFile
Definition blockmgr.h:113
BlockRequest(int nBlock, const AsyncTask &task)
Start a request with its first task.
std::list< AsyncTask > mTasks
Definition blockmgr.h:133
int mBlockNum
Definition blockmgr.h:132