|
vitrio 0.1.4
High-throughput image I/O for Cryo-Electron Microscopy (CryoEM)
|
A provider that keeps the readers it was last asked for. More...
#include <vitrio/caching_image_reader_provider.hpp>


Public Member Functions | |
| caching_image_reader_provider (std::shared_ptr< image_reader_provider > backing, std::size_t capacity) | |
| Construct a cache in front of another provider. | |
| std::size_t | get_capacity () const noexcept |
| Get the number of readers this may keep open at once. | |
| std::size_t | get_reader_count () const noexcept |
| Get how many readers are kept open. | |
| std::shared_ptr< const image_reader > | acquire (const std::string &key) override |
| Get the reader a key names. | |
Public Member Functions inherited from vitrio::image_reader_provider | |
| image_reader_provider (const image_reader_provider &other)=delete | |
| image_reader_provider (image_reader_provider &&other)=delete | |
| image_reader_provider & | operator= (const image_reader_provider &other)=delete |
| image_reader_provider & | operator= (image_reader_provider &&other)=delete |
A provider that keeps the readers it was last asked for.
Opening a file costs a system call and a header read, which asking for the same few files over and over repeats for nothing. This keeps a bounded number of readers open, each under the key it was asked for with, and evicts the least recently asked for when it is full. A key it holds is served without opening anything, and becomes the last to be evicted.
It is a decorator over another provider, not a second opener: on a miss it asks its backing provider and keeps what it gets, so it caches the readers of any provider alike.
The capacity is a file descriptor budget, which is why it is stated in entries rather than in bytes.
shared_ptr means the one not kept stays alive as long as it is read through, and so does an evicted one. | vitrio::caching_image_reader_provider::caching_image_reader_provider | ( | std::shared_ptr< image_reader_provider > | backing, |
| std::size_t | capacity | ||
| ) |
Construct a cache in front of another provider.
| backing | The provider asked on a miss. |
| capacity | Most readers to keep open at once. Must be greater than zero. |
| std::invalid_argument | If backing is null or capacity is zero. |
|
overridevirtual |
Get the reader a key names.
Shared ownership rather than a reference, so that a reader the provider stops keeping stays alive for as long as it is still read through.
| key | Key of the file to read, such as its path. |
| image_file_error | If the file does not exist or can not be read. |
| unsupported_operation_error | If no format can read the file. |
| image_file_format_error | If the file is malformed or truncated. |
Implements vitrio::image_reader_provider.
|
noexcept |
Get the number of readers this may keep open at once.
|
noexcept |
Get how many readers are kept open.