|
wavelength 1.0.0
|
Cache of disc blocks that ArkFile reads go through. More...
#include <blockmgr.h>

Public Member Functions | |
| void | Init () |
| Build the blocks of the cache. | |
| 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. | |
| 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. | |
| void | AddRequest (const AsyncTask &task) |
| Queue a task, joining the request for its block or inserting a new one in block order. | |
| void | Poll () |
| Finish the block that loaded, completing its tasks, and start loading the next request. | |
| Block * | FindBlock (int nBlock) |
| Find the block holding a block of the disc. | |
| Block * | FindOldestBlock () |
| Find the block used longest ago. | |
| const std::vector< std::unique_ptr< Block > > & | GetBlocks () const |
| void | Init () |
| Take the block buffers. | |
| void | GetAssociatedBlocks (__int64 offset, int bytes, int &firstBlock, int &numBlocks, int &blockSize) |
| Report the blocks a range of the archive covers. | |
| void | KillBlockRequests (ArkFile *file) |
| Drop every waiting read of a file, and every request left with no read unless its block is loading. | |
| char * | GetBlockData (int blockNum) |
| Report the data of a loaded block and mark the block as just used. | |
| void | AddRequest (const AsyncTask &task) |
| Queue a read on the request of its block, creating the request when needed. | |
| void | Poll () |
| Finish the loading block and satisfy its reads, then start loading the next requested block. | |
| Block * | FindBlock (int blockNum) |
| Find the buffer of a block. | |
| Block * | GetOldestBlock () |
| Find the least recently used buffer. | |
Static Public Member Functions | |
| static bool | ReadDone () |
| Report whether the read of the drive finished. | |
| static int | ReadError () |
| Report the error of the last read of the drive. | |
| static bool | Read (int nSector, int nCount, void *pBuffer) |
| Start reading sectors of the disc. | |
Public Attributes | |
| std::vector< Block * > | mBlocks |
| Block * | mLoadingBlock |
Cache of disc blocks that ArkFile reads go through.
Cache of archive blocks that satisfies the reads of ArkFile.
The class is not polymorphic and emits no RTTI, and the name is inferred. One block loads at a time. Requests are kept sorted by block, and the oldest unused block takes the next load.
The object is 0x18 bytes. One block loads at a time, into the least recently used buffer, and the requests stay sorted by block.
| void BlockMgr::Init | ( | ) |
Build the blocks of the cache.
| void BlockMgr::GetBlockSpan | ( | long long | nOffset, |
| int | nBytes, | ||
| int * | pnFirst, | ||
| int * | pnCount, | ||
| int * | pnBlockSize ) |
Report the blocks a run of bytes of the disc covers.
| nOffset | The first byte. |
| nBytes | The number of bytes. |
| pnFirst | Receives the first block. |
| pnCount | Receives the number of blocks, at least 1. |
| pnBlockSize | Receives the size of a block in bytes. |
| void BlockMgr::KillBlockRequests | ( | ArkFile * | pFile | ) |
Drop every task of a file, and every request left with no task unless its block is loading.
| pFile | The file. |
| int BlockMgr::SectorToByte | ( | int | nSector | ) |
Report the byte of the disc a sector starts at.
| nSector | The sector. |
| char * BlockMgr::GetBlockData | ( | int | nBlock | ) |
Report the data of a loaded block and mark the block used.
| nBlock | The block of the disc. |
| void BlockMgr::AddRequest | ( | const AsyncTask & | task | ) |
Queue a task, joining the request for its block or inserting a new one in block order.
| task | The task. |
| void BlockMgr::Poll | ( | ) |
Finish the block that loaded, completing its tasks, and start loading the next request.
A read that failed is started again.
| Block * BlockMgr::FindBlock | ( | int | nBlock | ) |
Find the block holding a block of the disc.
| nBlock | The block of the disc. |
| Block * BlockMgr::FindOldestBlock | ( | ) |
Find the block used longest ago.
|
static |
Report whether the read of the drive finished.
|
static |
Report the error of the last read of the drive.
|
static |
Start reading sectors of the disc.
| nSector | The first sector. |
| nCount | The number of sectors. |
| pBuffer | Receives the sectors. |
|
inline |
| void BlockMgr::Init | ( | ) |
Take the block buffers.
| void BlockMgr::GetAssociatedBlocks | ( | __int64 | offset, |
| int | bytes, | ||
| int & | firstBlock, | ||
| int & | numBlocks, | ||
| int & | blockSize ) |
Report the blocks a range of the archive covers.
| offset | The offset of the range. |
| bytes | The size of the range. |
| firstBlock | Receives the first block. |
| numBlocks | Receives the number of blocks. |
| blockSize | Receives the size of a block. |
| void BlockMgr::KillBlockRequests | ( | ArkFile * | file | ) |
Drop every waiting read of a file, and every request left with no read unless its block is loading.
| file | The file. |
| char * BlockMgr::GetBlockData | ( | int | blockNum | ) |
Report the data of a loaded block and mark the block as just used.
| blockNum | The block. |
| void BlockMgr::AddRequest | ( | const AsyncTask & | task | ) |
Queue a read on the request of its block, creating the request when needed.
| task | The read. |
| void BlockMgr::Poll | ( | ) |
Finish the loading block and satisfy its reads, then start loading the next requested block.
| Block * BlockMgr::FindBlock | ( | int | blockNum | ) |
Find the buffer of a block.
| blockNum | The block. |
| Block * BlockMgr::GetOldestBlock | ( | ) |
Find the least recently used buffer.
| std::vector<Block *> BlockMgr::mBlocks |
The block buffers.
| Block* BlockMgr::mLoadingBlock |
The buffer being loaded, or null.