#include <file.h>
Inheritance diagram for ost::MappedFile::
Public Methods | |
MappedFile (const char *fname, Access mode) | |
Open a file for mapping. More... | |
MappedFile (const char *fname, Access mode, size_t size) | |
Create if not exists, and map a file of specified size into memory. More... | |
MappedFile (const char *fname, pos_t offset, size_t size, Access mode) | |
Map a portion or all of a specified file in the specified shared memory access mode. More... | |
virtual | ~MappedFile () |
Release a mapped section of memory associated with a file. More... | |
void | sync (void) |
Synchronize the contents of the mapped portion of memory with the disk file and wait for completion. More... | |
void | sync (char *address, size_t len) |
Synchronize a segment of memory mapped from a segment fetch. More... | |
void | update (size_t offset=0, size_t len=0) |
Map a portion of the memory mapped from the file back to the file and do not wait for completion. More... | |
void | update (char *address, size_t len) |
Update a mapped region back to disk as specified by address and length. More... | |
void | release (char *address, size_t len) |
Release (unmap) a memory segment. More... | |
char* | fetch (size_t offset=0) |
Fetch a pointer to an offset within the memory mapped portion of the disk file. More... | |
char* | fetch (off_t pos, size_t len) |
Fetch and map a portion of a disk file to a logical memory block. More... | |
bool | lock (void) |
Lock the currently mapped portion of a file. More... | |
void | unlock (void) |
Unlock a locked mapped portion of a file. More... | |
size_t | pageAligned (size_t size) |
Compute map size to aligned page boundry. More... |
This portable class works under both Posix via mmap and under the win32 API. A mapped file can be referenced directly by it's memory segment. One can map and unmap portions of a file on demand, and update changed memory pages mapped from files immediately through sync().
|
Open a file for mapping. More than one segment of a file may be mapped into seperate regions of memory.
|
|
Create if not exists, and map a file of specified size into memory.
|
|
Map a portion or all of a specified file in the specified shared memory access mode. Valid mapping modes include mappedRead, mappedWrite, and mappedReadWrite.
|
|
Release a mapped section of memory associated with a file. The mapped area is updated back to disk. |
|
Fetch and map a portion of a disk file to a logical memory block.
|
|
Fetch a pointer to an offset within the memory mapped portion of the disk file. This really is used for convience of matching operations between Update and Fetch, as one could simply have accessed the base pointer where the file was mapped directly.
|
|
Lock the currently mapped portion of a file.
|
|
Compute map size to aligned page boundry.
|
|
Release (unmap) a memory segment.
|
|
Synchronize a segment of memory mapped from a segment fetch.
|
|
Synchronize the contents of the mapped portion of memory with the disk file and wait for completion. This assures the memory mapped from the file is written back. |
|
Unlock a locked mapped portion of a file.
|
|
Update a mapped region back to disk as specified by address and length.
|
|
Map a portion of the memory mapped from the file back to the file and do not wait for completion. This is useful when mapping a database file and updating a single record.
|