Construct or access a named section of memory.
More...
#include <mapped.h>
|
caddr_t | addr (void) |
| Get starting address of mapped segment. More...
|
|
bool | copy (size_t offset, void *buffer, size_t size) const |
| Copy memory from specific offset within the mapped memory segment. More...
|
|
size_t | len (void) const |
| Get size of mapped segment. More...
|
|
| MappedMemory (const char *name, size_t size) |
| Construct a read/write access mapped shared segment of memory of a known size. More...
|
|
| MappedMemory (const char *name) |
| Provide read-only mapped access to an existing named shared memory segment. More...
|
|
void * | offset (size_t offset) const |
| Get memory from a specific offset within the mapped memory segment. More...
|
|
| operator bool () const |
| Test if map active. More...
|
|
bool | operator! () const |
| Test if map is inactive. More...
|
|
void | release (void) |
| Unmap memory segment.
|
|
void * | sbrk (size_t size) |
| Extend size of managed heap on shared memory segment. More...
|
|
virtual | ~MappedMemory () |
| Unmap memory segment.
|
|
|
static void | disable (void) |
| An API that allows "disabling" of publishing shared memory maps. More...
|
|
static void | remove (const char *name) |
| Destroy a previously existing memory segment under the specified name. More...
|
|
|
void | create (const char *name, size_t size=(size_t) 0) |
| Supporting function to construct a new or access an existing shared memory segment. More...
|
|
|
bool | erase |
|
char | idname [65] |
|
size_t | size |
|
size_t | used |
|
Construct or access a named section of memory.
A logical name is used which might map to something that is invoked from a call like shm_open or a named w32 mapped swap segment. This is meant to support mapping a vector onto shared memory and is often used as a supporting class for our shared memory access templates.
- Author
- David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org
Definition at line 59 of file mapped.h.
◆ MappedMemory() [1/2]
ucommon::MappedMemory::MappedMemory |
( |
const char * |
name, |
|
|
size_t |
size |
|
) |
| |
Construct a read/write access mapped shared segment of memory of a known size.
This constructs a new memory segment.
- Parameters
-
name | of segment. |
size | of segment. |
◆ MappedMemory() [2/2]
ucommon::MappedMemory::MappedMemory |
( |
const char * |
name | ) |
|
Provide read-only mapped access to an existing named shared memory segment.
The size of the map is found by the size of the already existing segment.
- Parameters
-
◆ addr()
caddr_t ucommon::MappedMemory::addr |
( |
void |
| ) |
|
|
inline |
Get starting address of mapped segment.
- Returns
- starting address of mapped segment.
Definition at line 169 of file mapped.h.
◆ copy()
bool ucommon::MappedMemory::copy |
( |
size_t |
offset, |
|
|
void * |
buffer, |
|
|
size_t |
size |
|
) |
| const |
Copy memory from specific offset within the mapped memory segment.
This function assures the copy is not in the middle of being modified.
- Parameters
-
offset | from start of segment. |
buffer | to copy into. |
size | of object to copy. |
- Returns
- true on success.
◆ create()
void ucommon::MappedMemory::create |
( |
const char * |
name, |
|
|
size_t |
size = (size_t) 0 |
|
) |
| |
|
protected |
Supporting function to construct a new or access an existing shared memory segment.
Used by primary constructors.
- Parameters
-
name | of segment to create or access. |
size | of segment if creating new. Use 0 for read-only access. |
◆ disable()
static void ucommon::MappedMemory::disable |
( |
void |
| ) |
|
|
static |
An API that allows "disabling" of publishing shared memory maps.
This may be useful when an app doesn't want to use shared memory as a runtime or build option, but does not want to have to be "recoded" explicitly for non-shared memory either. Basically it substitutes a dummy map running on the local heap.
◆ len()
size_t ucommon::MappedMemory::len |
( |
void |
| ) |
const |
|
inline |
Get size of mapped segment.
- Returns
- size of mapped segment.
Definition at line 162 of file mapped.h.
◆ offset()
void* ucommon::MappedMemory::offset |
( |
size_t |
offset | ) |
const |
Get memory from a specific offset within the mapped memory segment.
- Parameters
-
offset | from start of segment. Will fault if past end. |
- Returns
- address of offset.
◆ operator bool()
ucommon::MappedMemory::operator bool |
( |
| ) |
const |
|
inline |
Test if map active.
- Returns
- true if active map.
Definition at line 122 of file mapped.h.
◆ operator!()
bool ucommon::MappedMemory::operator! |
( |
| ) |
const |
|
inline |
Test if map is inactive.
- Returns
- true if map inactive.
Definition at line 129 of file mapped.h.
◆ remove()
static void ucommon::MappedMemory::remove |
( |
const char * |
name | ) |
|
|
static |
Destroy a previously existing memory segment under the specified name.
This is used both before creating a new one, and after a publishing process unmaps the segment it created.
- Parameters
-
name | of segment to remove. |
◆ sbrk()
void* ucommon::MappedMemory::sbrk |
( |
size_t |
size | ) |
|
Extend size of managed heap on shared memory segment.
This does not change the size of the mapped segment in any way, only that of any heap space that is being allocated and used from the mapped segment.
- Returns
- start of space from map.
- Parameters
-
size | of space requested. Will fault if past end of segment. |
The documentation for this class was generated from the following file: