casa
$Rev:20696$
|
Memory-mapped IO on a file. More...
#include <MMapIO.h>
Public Member Functions | |
MMapIO (const RegularFile ®ularFile, ByteIO::OpenOption=ByteIO::Old) | |
Open the given file and map it entirely into memory with read access. | |
~MMapIO () | |
Destructor. | |
Private Member Functions | |
MMapIO (const MMapIO &) | |
Forbid copy constructor and assignment. | |
MMapIO & | operator= (const MMapIO &) |
Memory-mapped IO on a file.
Memory-mapped IO lets the OS take care of caching file segments. This is particularly useful for the Tiled Storage Manager which keeps a cache of tiles. When using memory-mapped IO it does not need to do that anymore.
On 32-bit systems its use is limited because for large files the 4 GB memory space is insufficient. However, for 64-bit systems the memory space is large enough to make use of it.
In the general case there is direct access to the mapped file space. The read and write methods copies the data into/from a buffer. However, to avoid the copying it is possible to get a direct pointer to the mapped data. This should be used with care, because writing to it will cause a segmentation if the file is readonly. If the file is writable, writing into the mapped data segment means changing the file contents.
casa::MMapIO::MMapIO | ( | const RegularFile & | regularFile, |
ByteIO::OpenOption | = ByteIO::Old |
||
) | [explicit] |
Open the given file and map it entirely into memory with read access.
The map has write access if the file is opened for write.
Destructor.
It will flush and unmap the file.
casa::MMapIO::MMapIO | ( | const MMapIO & | ) | [private] |
Forbid copy constructor and assignment.