A cache for full-resolution image tiles.
More...
#include <TileCache.h>
|
| TileCache () |
| Default constructor.
|
|
| TileCache (int capacity) |
| Constructor used by Frame.
|
|
TilePtr | Peek (Key key) |
| Retrieve a tile from the cache without modifying its access time.
|
|
TilePtr | Get (Key key, std::shared_ptr< FileLoader > loader, std::mutex &image_mutex) |
| Retrieve a tile from the cache.
|
|
void | Reset (int32_t z, int32_t stokes, int capacity=0) |
| Reset the cache for a new Z coordinate and/or Stokes coordinate, clearing all tiles.
|
|
|
static Key | ChunkKey (Key tile_key) |
| Calculate the key for the chunk that contains the given tile.
|
|
|
TilePtr | UnsafePeek (Key key) |
| Retrieve a tile from the cache.
|
|
void | Touch (Key key) |
| Update the access time of a tile.
|
|
bool | LoadChunk (Key chunk_key, std::shared_ptr< FileLoader > loader, std::mutex &image_mutex) |
| Load a chunk from the file into the cache.
|
|
|
int32_t | _z |
| The current Z coordinate.
|
|
int32_t | _stokes |
| The current Stokes coordinate.
|
|
std::list< TilePair > | _queue |
| The queue which stores tiles in order of access time.
|
|
std::unordered_map< Key, std::list< TilePair >::iterator > | _map |
| The map which stores references to tiles in the queue.
|
|
int | _capacity |
| The maximum number of tiles which may be stored in the cache.
|
|
std::mutex | _tile_cache_mutex |
| The cache mutex.
|
|
std::vector< float > | _chunk |
| The vector used to load chunk data.
|
|
std::shared_ptr< TilePool > | _pool |
| The pool used to store reusable tile objects.
|
|
A cache for full-resolution image tiles.
A tile cache is used by Frame instead of a full image cache if its FileLoader reports that it should be used. Currently only the Hdf5Loader implements this. This implementation uses a pool to store reusable tile objects. This is an LRU cache: when tile capacity is reached, the least recently used tile is discarded first.
- See also
- FileLoader::UseTileCache
-
TilePool
-
TileCacheKey
◆ Key
◆ TileIter
◆ TilePair
◆ TileCache() [1/2]
carta::TileCache::TileCache |
( |
| ) |
|
|
inline |
◆ TileCache() [2/2]
TileCache::TileCache |
( |
int |
capacity | ) |
|
Constructor used by Frame.
- Parameters
-
capacity | The cache capacity |
◆ ChunkKey()
Calculate the key for the chunk that contains the given tile.
- Parameters
-
- Returns
- The chunk key
HDF5 files produced by the fits2idia converter currently use a chunk size which is twice the tile size in each dimension. This means that each chunk is a block of 2x2 tiles.
- See also
- LoadChunk
◆ Get()
Retrieve a tile from the cache.
- Parameters
-
This function locks the cache because it modifies the cache state.
◆ LoadChunk()
bool TileCache::LoadChunk |
( |
Key |
chunk_key, |
|
|
std::shared_ptr< FileLoader > |
loader, |
|
|
std::mutex & |
image_mutex |
|
) |
| |
|
private |
Load a chunk from the file into the cache.
- Parameters
-
chunk_key | The key of the chunk. |
loader | The file loader. |
image_mutex | The image mutex to pass to FileLoader::GetChunk. |
When a requested tile is not found in the cache, for efficiency we read the entire chunk of data which contains that tile, and add all the tiles contained in the chunk into the cache at once.
- See also
- ChunkKey
◆ Peek()
Retrieve a tile from the cache without modifying its access time.
- Parameters
-
This is a read-only operation and does not lock the cache.
◆ Reset()
void TileCache::Reset |
( |
int32_t |
z, |
|
|
int32_t |
stokes, |
|
|
int |
capacity = 0 |
|
) |
| |
Reset the cache for a new Z coordinate and/or Stokes coordinate, clearing all tiles.
- Parameters
-
z | The new Z coordinate |
stokes | The new Stokes coordinate |
capacity | The new capacity |
This function locks the cache because it modifies the cache state.
◆ Touch()
void TileCache::Touch |
( |
Key |
key | ) |
|
|
private |
Update the access time of a tile.
- Parameters
-
This function does not lock the cache, and assumes that the tile is in the cache.
◆ UnsafePeek()
Retrieve a tile from the cache.
- Parameters
-
This function does not lock the cache, and assumes that the tile is in the cache.
◆ _capacity
int carta::TileCache::_capacity |
|
private |
The maximum number of tiles which may be stored in the cache.
◆ _chunk
std::vector<float> carta::TileCache::_chunk |
|
private |
The vector used to load chunk data.
◆ _map
std::unordered_map<Key, std::list<TilePair>::iterator> carta::TileCache::_map |
|
private |
The map which stores references to tiles in the queue.
◆ _pool
std::shared_ptr<TilePool> carta::TileCache::_pool |
|
private |
The pool used to store reusable tile objects.
◆ _queue
std::list<TilePair> carta::TileCache::_queue |
|
private |
The queue which stores tiles in order of access time.
◆ _stokes
int32_t carta::TileCache::_stokes |
|
private |
The current Stokes coordinate.
◆ _tile_cache_mutex
std::mutex carta::TileCache::_tile_cache_mutex |
|
private |
◆ _z
int32_t carta::TileCache::_z |
|
private |
The current Z coordinate.
The documentation for this class was generated from the following files: