API to manage and manipulate memory shared between different processes
More...
#include <SharedMemory.hpp>
|
|
typedef boost::interprocess::managed_shared_memory | SharedMemoryImpl |
| |
|
typedef SharedMemoryImpl::segment_manager | SegmentManager |
| |
|
typedef boost::interprocess::permissions | SharedMemoryPermission |
| |
| template<class T > |
| using | Ptr = boost::interprocess::offset_ptr< T > |
| | Returned pointer types are shared memory based offset pointer. More...
|
| |
|
| | SharedMemory (const char *name) |
| | Opens an existing shared memory. More...
|
| |
| | SharedMemory (const char *name, size_t memorySize) |
| | Creates an non-existing instance, throws if yet exists. More...
|
| |
| | ~SharedMemory (void)=default |
| | Deallocates the memory for this management object but not the memory shared between processes. More...
|
| |
| void | Remove (void) |
| | Removes the shared memory from the system. More...
|
| |
| const Arp::String & | GetName (void) const |
| | Returns the name of the memory object. More...
|
| |
| size_t | GetSize (void) const |
| | Returns the capacity of the shared memory in bytes. More...
|
| |
| byte * | Allocate (size_t size) |
| | Tries to allocate size amount of bytes in the memory. More...
|
| |
| void | Deallocate (byte *pMemory) |
| | Marks the memory pointed to by pMemory available for new allocation requests. More...
|
| |
| template<class T > |
| Ptr< T > | Get (const char *name) |
| | Tries to find a previously allocated named object. More...
|
| |
| template<class T , typename ... TArgs> |
| Ptr< T > | GetOrConstruct (const char *name, TArgs... args) |
| | Tries to find object identified by name, creates a new one if the object does not exists yet. More...
|
| |
| template<class T , typename ... TArgs> |
| Ptr< T > | Construct (const char *name, TArgs... args) |
| | Creates a named object in the shared memory. More...
|
| |
| template<class T , typename ... TArgs> |
| Ptr< T > | ConstructUnnamed (TArgs... args) |
| | Creates an unnamed object in the shared memory. More...
|
| |
| template<class T > |
| void | Destroy (const char *name) |
| | Deallocates the object in the shared memory, also calling the objects destructor. More...
|
| |
| size_t | GetFreeMemory (void) const |
| | Obtain the number of free bytes in the shared memory. More...
|
| |
| void | ZeroFreeMemory (void) |
| | Writes zero in all bytes not yet allocated. More...
|
| |
| bool | AllMemoryDeallocated (void) |
| | Checks if all memory has been deallocated. More...
|
| |
| bool | CheckSanity (void) |
| | Performs a sanity check over the shared memory. More...
|
| |
API to manage and manipulate memory shared between different processes
◆ Ptr
Returned pointer types are shared memory based offset pointer.
◆ SharedMemory() [1/2]
| Arp::System::Commons::Ipc::SharedMemory::SharedMemory |
( |
const char * |
name | ) |
|
|
inline |
Opens an existing shared memory.
- Parameters
-
| name | Name identifing the shared memory to be opened. |
◆ SharedMemory() [2/2]
| Arp::System::Commons::Ipc::SharedMemory::SharedMemory |
( |
const char * |
name, |
|
|
size_t |
memorySize |
|
) |
| |
Creates an non-existing instance, throws if yet exists.
- Parameters
-
| name | Name identifing the shared memory to be opened. |
| memorySize | The memory size in bytes allocated for the new shared memory. |
◆ ~SharedMemory()
| Arp::System::Commons::Ipc::SharedMemory::~SharedMemory |
( |
void |
| ) |
|
|
default |
Deallocates the memory for this management object but not the memory shared between processes.
◆ AllMemoryDeallocated()
| bool Arp::System::Commons::Ipc::SharedMemory::AllMemoryDeallocated |
( |
void |
| ) |
|
|
inline |
Checks if all memory has been deallocated.
- Returns
- true if all memory is deallocated, otherwise false is returned.
◆ Allocate()
| byte * Arp::System::Commons::Ipc::SharedMemory::Allocate |
( |
size_t |
size | ) |
|
|
inline |
Tries to allocate size amount of bytes in the memory.
- Parameters
-
| size | The desired size in bytes of the allocated memory block. |
- Returns
- Pointer to allocated memory area.
◆ CheckSanity()
| bool Arp::System::Commons::Ipc::SharedMemory::CheckSanity |
( |
void |
| ) |
|
|
inline |
Performs a sanity check over the shared memory.
- Returns
- True if no errors are detected, otherwise false is returned.
◆ Construct()
template<class T , typename ... TArgs>
| SharedMemory::Ptr< T > Arp::System::Commons::Ipc::SharedMemory::Construct |
( |
const char * |
name, |
|
|
TArgs... |
args |
|
) |
| |
|
inline |
Creates a named object in the shared memory.
- Parameters
-
| name | Name associated with the object. |
| args | Arguments passed to the objects constructor. |
- Returns
- Pointer to created object on success, otherwise nullptr is returned.
◆ ConstructUnnamed()
template<class T , typename ... TArgs>
| SharedMemory::Ptr< T > Arp::System::Commons::Ipc::SharedMemory::ConstructUnnamed |
( |
TArgs... |
args | ) |
|
|
inline |
Creates an unnamed object in the shared memory.
- Parameters
-
| args | Arguments passed to the objects constructor. |
- Returns
- Pointer to created object on success, otherwise nullptr is returned.
◆ Deallocate()
| void Arp::System::Commons::Ipc::SharedMemory::Deallocate |
( |
byte * |
pMemory | ) |
|
|
inline |
Marks the memory pointed to by pMemory available for new allocation requests.
- Parameters
-
| pMemory | Pointer to begin of previously allocated memory area. |
◆ Destroy()
template<class T >
| void Arp::System::Commons::Ipc::SharedMemory::Destroy |
( |
const char * |
name | ) |
|
|
inline |
Deallocates the object in the shared memory, also calling the objects destructor.
- Parameters
-
| name | Name identifying the object to destroy. |
◆ Get()
template<class T >
| SharedMemory::Ptr< T > Arp::System::Commons::Ipc::SharedMemory::Get |
( |
const char * |
name | ) |
|
|
inline |
Tries to find a previously allocated named object.
- Returns
- Pointer to object on success, otherwise a nullptr is returned.
◆ GetFreeMemory()
| size_t Arp::System::Commons::Ipc::SharedMemory::GetFreeMemory |
( |
void |
| ) |
const |
|
inline |
Obtain the number of free bytes in the shared memory.
- Returns
- Amount of free bytes in the shared memory.
◆ GetName()
| const Arp::String & Arp::System::Commons::Ipc::SharedMemory::GetName |
( |
void |
| ) |
const |
|
inline |
Returns the name of the memory object.
- Returns
- Name of memory object.
◆ GetOrConstruct()
template<class T , typename ... TArgs>
| SharedMemory::Ptr< T > Arp::System::Commons::Ipc::SharedMemory::GetOrConstruct |
( |
const char * |
name, |
|
|
TArgs... |
args |
|
) |
| |
|
inline |
Tries to find object identified by name, creates a new one if the object does not exists yet.
- Parameters
-
| name | Name identifying the object in the memory after allocation. |
| args | Arguments passed to constructor of object. |
- Returns
- Pointer to object on success, otherwise a nullptr is returned.
◆ GetSize()
| size_t Arp::System::Commons::Ipc::SharedMemory::GetSize |
( |
void |
| ) |
const |
|
inline |
Returns the capacity of the shared memory in bytes.
- Returns
- Capacity of the shared memory.
◆ Remove()
| void Arp::System::Commons::Ipc::SharedMemory::Remove |
( |
void |
| ) |
|
|
inline |
Removes the shared memory from the system.
◆ ZeroFreeMemory()
| void Arp::System::Commons::Ipc::SharedMemory::ZeroFreeMemory |
( |
void |
| ) |
|
|
inline |
Writes zero in all bytes not yet allocated.
◆ memoryName
| Arp::String Arp::System::Commons::Ipc::SharedMemory::memoryName |
|
protected |
Name of memory identifying the shared memory inside the operating system.
◆ sharedMemoryImpl
| SharedMemoryImpl Arp::System::Commons::Ipc::SharedMemory::sharedMemoryImpl |
|
protected |
Actual implementation of the shared memory functionality.
The documentation for this class was generated from the following file: