#include "MappedRegion.h"
|
| | MappedRegion ()=default |
| | MappedRegion (const MappedRegion &)=delete |
| MappedRegion & | operator= (const MappedRegion &)=delete |
| std::size_t | openFile (const char *filename, bool read_only) |
| | Open (creating if absent) the backing file.
|
| void | resizeFile (std::size_t length) |
| | Set the backing file's size.
|
| void | map (std::size_t length) |
| | Establish the initial region of length bytes over the file.
|
| void | remap (std::size_t new_length) |
| | Grow the region to new_length, preserving existing content.
|
| void | sync () |
| | Flush the region to the backing file (no-op when read-only).
|
| void | close () |
| | Write back (if writable) and release the region and file.
|
| void * | base () const |
| std::size_t | length () const |
|
| int | fd_ = -1 |
| | Backing file descriptor.
|
| void * | base_ = nullptr |
| | Base of the mapped region / heap buffer.
|
| std::size_t | length_ = 0 |
| | Current region length in bytes.
|
| bool | read_only_ = false |
| | Opened read-only (no write-back).
|
Definition at line 41 of file MappedRegion.h.
◆ MappedRegion() [1/2]
| MappedRegion::MappedRegion |
( |
| ) |
|
|
default |
◆ MappedRegion() [2/2]
◆ base()
| void * MappedRegion::base |
( |
| ) |
const |
|
inline |
◆ close()
| void MappedRegion::close |
( |
| ) |
|
|
inline |
Write back (if writable) and release the region and file.
Definition at line 140 of file MappedRegion.h.
◆ length()
| std::size_t MappedRegion::length |
( |
| ) |
const |
|
inline |
◆ map()
| void MappedRegion::map |
( |
std::size_t | length | ) |
|
|
inline |
Establish the initial region of length bytes over the file.
Definition at line 86 of file MappedRegion.h.
◆ openFile()
| std::size_t MappedRegion::openFile |
( |
const char * | filename, |
|
|
bool | read_only ) |
|
inline |
Open (creating if absent) the backing file.
- Returns
- The file's current size in bytes (0 if newly created).
Definition at line 56 of file MappedRegion.h.
◆ operator=()
◆ remap()
| void MappedRegion::remap |
( |
std::size_t | new_length | ) |
|
|
inline |
Grow the region to new_length, preserving existing content.
Definition at line 106 of file MappedRegion.h.
◆ resizeFile()
| void MappedRegion::resizeFile |
( |
std::size_t | length | ) |
|
|
inline |
Set the backing file's size.
The shared-mmap backend must pre-size the file (mmap maps file-backed pages). The heap-buffer backend does not: it allocates the buffer and sync() extends the file with pwrite. Crucially, leaving the file unsized until the first sync() means a fresh file that is never synced (e.g. a backend that aborts before write-back) stays empty on disk and is re-initialised cleanly on reopen, rather than persisting as a full-size, never-written file whose zero header fails magic validation.
Definition at line 76 of file MappedRegion.h.
◆ sync()
| void MappedRegion::sync |
( |
| ) |
|
|
inline |
Flush the region to the backing file (no-op when read-only).
Definition at line 128 of file MappedRegion.h.
◆ base_
| void* MappedRegion::base_ = nullptr |
|
private |
Base of the mapped region / heap buffer.
Definition at line 43 of file MappedRegion.h.
◆ fd_
| int MappedRegion::fd_ = -1 |
|
private |
◆ length_
| std::size_t MappedRegion::length_ = 0 |
|
private |
◆ read_only_
| bool MappedRegion::read_only_ = false |
|
private |
The documentation for this class was generated from the following file: