SourcePro® 2024.1 |
SourcePro® API Reference Guide |
Caches fixed-length blocks to and from an associated RWFile. More...
#include <rw/cacheman.h>
Public Member Functions | |
RWCacheManager (RWFile *file, unsigned blocksz, size_t mxblks=10) | |
~RWCacheManager () | |
bool | flush () |
void | invalidate () |
bool | read (RWoffset locn, void *dat) |
bool | write (RWoffset locn, void *dat) |
Class RWCacheManager caches fixed-length blocks to and from an associated RWFile. The block size can be of any length and is set at construction time. The number of cached blocks can also be set at construction time.
Writes to the file may be deferred. Use member function flush() to have any pending writes performed.
RWCacheManager::RWCacheManager | ( | RWFile * | file, |
unsigned | blocksz, | ||
size_t | mxblks = 10 ) |
Constructs a cache for the RWFile pointed to by file. The length of the fixed-sized blocks is given by blocksz. The number of cached blocks is given by mxblks. If the total number of bytes cached would exceed the maximum value of an unsigned int
, RWCacheManager quietly caches a smaller number of blocks.
RWCacheManager::~RWCacheManager | ( | ) |
Performs any pending I/O operations (i.e., calls flush()) and deallocates any allocated memory.
bool RWCacheManager::flush | ( | ) |
Performs any pending I/O operations. Returns true
if the flush was successful, otherwise false
.
void RWCacheManager::invalidate | ( | ) |
Invalidates the cache.
bool RWCacheManager::read | ( | RWoffset | locn, |
void * | dat ) |
Returns the data located at offset locn of the associated RWFile. The data is put in the buffer pointed to by dat. This buffer must be at least as long as the block size specified when the cache was constructed. Returns true
if the operation was successful, otherwise false
.
bool RWCacheManager::write | ( | RWoffset | locn, |
void * | dat ) |
Writes the block of data pointed to by dat to the offset locn of the associated RWFile. The number of bytes written is given by the block size specified when the cache was constructed. The actual write to disk may be deferred. Use member function flush() to perform any pending writes. Returns true
if the operation was successful, otherwise false
.
Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |