POSIX Shared Memory Data Structures 1.0
High-performance lock-free data structures for inter-process communication
|
Metadata table for managing shared memory data structures. More...
#include <shm_table.h>
Classes | |
struct | entry |
Public Member Functions | |
shm_table_impl ()=default | |
bool | add (const char *name, size_t offset, size_t size, size_t elem_size=0, size_t num_elem=0) |
Add a new entry to the table. | |
bool | add (std::string_view name, size_t offset, size_t size, size_t elem_size=0, size_t num_elem=0) |
bool | erase (const char *name) |
bool | erase (std::string_view name) |
entry * | find (const char *name) |
Find an entry by name. | |
const entry * | find (const char *name) const |
entry * | find (std::string_view name) |
const entry * | find (std::string_view name) const |
size_t | get_total_allocated_size () const |
Get total allocated size (excluding the table itself) | |
size_t | get_entry_count () const |
Get number of active entries. | |
void | clear () |
Clear all entries (for initialization) | |
Static Public Member Functions | |
static constexpr size_t | size_bytes () |
Get the actual size of this table in bytes. | |
Static Public Attributes | |
static constexpr size_t | MAX_NAME_SIZE = MaxNameSize |
static constexpr size_t | MAX_ENTRIES = MaxEntries |
Metadata table for managing shared memory data structures.
Stored at the beginning of shared memory segment to allow dynamic discovery and management of data structures.
MaxNameSize | Maximum size for entry names (default 32) |
MaxEntries | Maximum number of entries in the table (default 64) |
Definition at line 20 of file shm_table.h.
|
default |
|
inline |
Add a new entry to the table.
name | Name of the resource that resides in shared memory. |
offset | Offset of the resource in shared memory. |
size | Total size of the resource in bytes. |
elem_size | Size of each element (for arrays/queues). |
num_elem | Number of elements. |
Definition at line 53 of file shm_table.h.
References shm_table_impl< MaxNameSize, MaxEntries >::find(), shm_table_impl< MaxNameSize, MaxEntries >::MAX_ENTRIES, and shm_table_impl< MaxNameSize, MaxEntries >::MAX_NAME_SIZE.
Referenced by shm_table_impl< MaxNameSize, MaxEntries >::add().
|
inline |
Definition at line 82 of file shm_table.h.
References shm_table_impl< MaxNameSize, MaxEntries >::add(), and shm_table_impl< MaxNameSize, MaxEntries >::MAX_NAME_SIZE.
|
inline |
Clear all entries (for initialization)
Definition at line 185 of file shm_table.h.
References shm_table_impl< MaxNameSize, MaxEntries >::entry::active, and shm_table_impl< MaxNameSize, MaxEntries >::MAX_ENTRIES.
|
inline |
Definition at line 91 of file shm_table.h.
References shm_table_impl< MaxNameSize, MaxEntries >::entry::active, and shm_table_impl< MaxNameSize, MaxEntries >::MAX_ENTRIES.
Referenced by shm_table_impl< MaxNameSize, MaxEntries >::erase().
|
inline |
Definition at line 106 of file shm_table.h.
References shm_table_impl< MaxNameSize, MaxEntries >::erase(), and shm_table_impl< MaxNameSize, MaxEntries >::MAX_NAME_SIZE.
|
inline |
Find an entry by name.
Definition at line 118 of file shm_table.h.
References shm_table_impl< MaxNameSize, MaxEntries >::MAX_ENTRIES.
Referenced by shm_table_impl< MaxNameSize, MaxEntries >::add(), shm_table_impl< MaxNameSize, MaxEntries >::find(), and shm_table_impl< MaxNameSize, MaxEntries >::find().
|
inline |
Definition at line 131 of file shm_table.h.
References shm_table_impl< MaxNameSize, MaxEntries >::MAX_ENTRIES.
|
inline |
Definition at line 144 of file shm_table.h.
References shm_table_impl< MaxNameSize, MaxEntries >::find(), and shm_table_impl< MaxNameSize, MaxEntries >::MAX_NAME_SIZE.
|
inline |
Definition at line 152 of file shm_table.h.
References shm_table_impl< MaxNameSize, MaxEntries >::find(), and shm_table_impl< MaxNameSize, MaxEntries >::MAX_NAME_SIZE.
|
inline |
Get number of active entries.
Definition at line 171 of file shm_table.h.
References shm_table_impl< MaxNameSize, MaxEntries >::MAX_ENTRIES.
|
inline |
Get total allocated size (excluding the table itself)
Definition at line 163 of file shm_table.h.
|
inlinestaticconstexpr |
Get the actual size of this table in bytes.
Definition at line 197 of file shm_table.h.
|
staticconstexpr |
Definition at line 24 of file shm_table.h.
Referenced by shm_table_impl< MaxNameSize, MaxEntries >::add(), shm_table_impl< MaxNameSize, MaxEntries >::clear(), shm_table_impl< MaxNameSize, MaxEntries >::erase(), example_large_simulation(), example_minimal_overhead(), shm_table_impl< MaxNameSize, MaxEntries >::find(), shm_table_impl< MaxNameSize, MaxEntries >::find(), and shm_table_impl< MaxNameSize, MaxEntries >::get_entry_count().
|
staticconstexpr |
Definition at line 23 of file shm_table.h.
Referenced by shm_table_impl< MaxNameSize, MaxEntries >::add(), shm_table_impl< MaxNameSize, MaxEntries >::add(), shm_table_impl< MaxNameSize, MaxEntries >::erase(), example_large_simulation(), example_minimal_overhead(), shm_table_impl< MaxNameSize, MaxEntries >::find(), and shm_table_impl< MaxNameSize, MaxEntries >::find().