resonance 1.0.1
Loading...
Searching...
No Matches
seccache.h
Go to the documentation of this file.
1#pragma once
2
4constexpr int kSectorCacheRowSize = 0x10000;
5
7constexpr int kSectorCacheFallbackSize = 0x80000;
8
10constexpr int kSectorCacheRowEmpty = -1;
11
19constexpr unsigned kSectorCacheLocked = 0x99999999;
20
22constexpr unsigned kSectorCacheStampCeiling = 0x7fffffff;
23
25constexpr unsigned kSectorCacheStampHalfway = 0x3fffffff;
26
28constexpr unsigned kSectorCacheStampRebase = 0x40000000;
29
37 int mFile;
38 int mSector;
39 unsigned mStamp;
40 void *mBuffer;
41};
42
55void SectorCacheInit(int nRows);
56
67
78void SectorCacheRemove(int nFile);
79
91SectorCacheRow *SectorCacheFind(int nFile, int nSector);
92
107SectorCacheRow *SectorCacheGetLRU(int nFile, int nSector);
108
121void SectorCacheLock(int nFile, int nSector);
122
133
146void UnlockCachedSector(int nFile, int nSector);
147
155
165
void SectorCacheDump()
Print every row through printf().
void SetSectorRowLocked(SectorCacheRow *pRow)
Lock one row against reuse.
SectorCacheRow * SectorCacheFind(int nFile, int nSector)
Find the row buffering a chunk.
void SectorCacheLock(int nFile, int nSector)
Lock the row buffering a chunk against reuse.
SectorCache gSectorCache
The one sector cache.
constexpr int kSectorCacheRowEmpty
Stored in a row's file and sector while the row buffers nothing.
Definition seccache.h:10
void UnlockCachedSector(int nFile, int nSector)
Release the lock on the row buffering a chunk.
void SectorCacheRemove(int nFile)
Drop every row that buffers a file.
void SectorCacheInit(int nRows)
Bring up the sector cache.
constexpr unsigned kSectorCacheStampRebase
The amount every stamp above the halfway mark is reduced by.
Definition seccache.h:28
constexpr unsigned kSectorCacheStampCeiling
Stamp the least-recently-used search starts from, above every stamp the clock produces.
Definition seccache.h:22
constexpr unsigned kSectorCacheLocked
Stamp that locks a row against reuse.
Definition seccache.h:19
void SectorCacheTerm()
Release every row and the row table.
SectorCacheRow * SectorCacheGetLRU(int nFile, int nSector)
Take the least recently used row for a chunk.
constexpr int kSectorCacheFallbackSize
The space the cache assumes when zones are switched off.
Definition seccache.h:7
constexpr int kSectorCacheRowSize
The number of bytes each row buffers, which is what the row count divides the zone by.
Definition seccache.h:4
constexpr unsigned kSectorCacheStampHalfway
A chosen stamp above this triggers the rebase that stops the clock from wrapping.
Definition seccache.h:25
One buffered run of a file.
Definition seccache.h:36
int mFile
Definition seccache.h:37
int mSector
Definition seccache.h:38
unsigned mStamp
Definition seccache.h:39
void * mBuffer
Definition seccache.h:40
The row table and its length.
Definition seccache.h:161
int mRowCount
Definition seccache.h:162
SectorCacheRow * mRows
Definition seccache.h:163