PLCnext API Documentation 23.6.0.37
|
API to manage and manipulate memory shared between different processes More...
#include <SharedMemory.hpp>
Public Member Functions | |
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. | |
void | Remove (void) |
Removes the shared memory from the system. | |
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 > | |
void | Destroy (const char *name) |
Deallocates the object in the shared memory, also calling the objects destructor. More... | |
template<class T , typename ... TArgs> | |
Ptr< T > | ConstructUnnamed (TArgs... args) |
Creates an unnamed object in the shared memory. More... | |
template<class T > | |
void | DestroyUnnamed (SharedMemory::Ptr< T > ptr) |
Deallocates the unnamed 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. | |
bool | AllMemoryDeallocated (void) |
Checks if all memory has been deallocated. More... | |
bool | CheckSanity (void) |
Performs a sanity check over the shared memory. More... | |
Protected Attributes | |
Arp::String | memoryName |
Name of memory identifying the shared memory inside the operating system. | |
SharedMemoryImpl | sharedMemoryImpl |
Actual implementation of the shared memory functionality. | |
API to manage and manipulate memory shared between different processes
|
inline |
Opens an existing shared memory.
name | Name identifing the shared memory to be opened. |
Arp::System::Commons::Ipc::SharedMemory::SharedMemory | ( | const char * | name, |
size_t | memorySize | ||
) |
Creates an non-existing instance, throws if yet exists.
name | Name identifing the shared memory to be opened. |
memorySize | The memory size in bytes allocated for the new shared memory. |
|
inline |
Checks if all memory has been deallocated.
|
inline |
Tries to allocate size
amount of bytes in the memory.
size | The desired size in bytes of the allocated memory block. |
|
inline |
Performs a sanity check over the shared memory.
|
inline |
Creates a named object in the shared memory.
name | Name associated with the object. |
args | Arguments passed to the objects constructor. |
|
inline |
Creates an unnamed object in the shared memory.
args | Arguments passed to the objects constructor. |
|
inline |
Marks the memory pointed to by pMemory
available for new allocation requests.
pMemory | Pointer to begin of previously allocated memory area. |
|
inline |
Deallocates the object in the shared memory, also calling the objects destructor.
name | Name identifying the object to destroy. |
|
inline |
Deallocates the unnamed object in the shared memory, also calling the objects destructor.
pMemory | Pointer to begin of previously allocated unnamed object. |
|
inline |
Tries to find a previously allocated named object.
|
inline |
Obtain the number of free bytes in the shared memory.
|
inline |
Returns the name of the memory object.
|
inline |
Tries to find object identified by name
, creates a new one if the object does not exists yet.
name | Name identifying the object in the memory after allocation. |
args | Arguments passed to constructor of object. |
|
inline |
Returns the capacity of the shared memory in bytes.