#include <ddtMemoryManager.hpp>
This class manages the handling of shared memories.
◆ DdtMemoryManager()
DdtMemoryManager::DdtMemoryManager |
( |
DdtLogger * |
logger, |
|
|
const std::string |
broker_port |
|
) |
| |
Constructor
- Parameters
-
logger | A DDT logger object (no transfer of ownership). |
broker_port | The port from the broker. Will be part of the shm identifier. |
◆ ~DdtMemoryManager()
DdtMemoryManager::~DdtMemoryManager |
( |
| ) |
|
|
virtualdefault |
◆ CheckIfShmExists()
bool DdtMemoryManager::CheckIfShmExists |
( |
const std::string |
data_stream_identifier | ) |
|
Checks if the shared memory specified by data stream identifier already exists in the shm_map.
- Parameters
-
data_stream_identifier | The data stream identifier. |
- Returns
- True if shared memory exists, false if not.
◆ CheckSpaceAvailability()
bool DdtMemoryManager::CheckSpaceAvailability |
( |
const int32_t |
max_data_sample_size, |
|
|
const int |
buffer_size |
|
) |
| |
|
protected |
Checks if the requested space is available on the system.
- Parameters
-
max_data_sample_size | The maximum data sample size. |
buffer_size | Buffer size specified by the user. |
- Returns
- True if the requested space is available, false if not.
◆ CreateSharedMemory()
int32_t DdtMemoryManager::CreateSharedMemory |
( |
const std::string |
data_stream_identifier, |
|
|
const int32_t |
max_data_sample_size, |
|
|
const int32_t |
number_of_samples |
|
) |
| |
Creates a Boost shared memory object and constructs a circular buffer. For each shared memory an accessor is created.
- Parameters
-
data_stream_identifier | The data stream identifier. |
max_data_sample_size | The maximum data sample size. |
number_of_samples | The Number of samples stored in the SHM ring buffer. |
- Return values
-
MEMORY_ERROR | Not enough memory. |
-1 | General error. |
1 | Success. |
◆ DeleteSharedMemory()
bool DdtMemoryManager::DeleteSharedMemory |
( |
const std::string |
data_stream_identifier | ) |
|
Removes the shared memory and updates the shm map and the SharedMemories.txt file.
- Parameters
-
data_stream_identifier | The data stream identifier. |
- Returns
- True if shared memory was successfully deleted, false if not.
◆ get_max_data_sample_size()
int32_t DdtMemoryManager::get_max_data_sample_size |
( |
const std::string |
data_stream_identifier | ) |
|
Returns max_data_sample_size.
- Parameters
-
data_stream_identifier | The data stream identifier. |
- Returns
- The maximum data sample size.
◆ get_memory_accessor()
DdtMemoryAccessor * DdtMemoryManager::get_memory_accessor |
( |
const std::string |
data_stream_identifier | ) |
|
Returns memory_accessor.
- Parameters
-
data_stream_identifier | The data stream identifier. |
- Returns
- The accessor to the shared memory.
◆ get_number_of_samples()
int32_t DdtMemoryManager::get_number_of_samples |
( |
const std::string |
data_stream_identifier | ) |
|
Returns number_of_samples.
- Parameters
-
data_stream_identifier | The data stream identifier. |
- Returns
- The Number of samples stored in the SHM ring buffer.
◆ get_shm_id()
std::string DdtMemoryManager::get_shm_id |
( |
const std::string |
data_stream_identifier | ) |
const |
Returns a string combination of port and data stream identifier which is the shm identifier.
- Parameters
-
data_stream_identifier | The data stream identifier. |
- Returns
- The SHM identifier.
the shm id is created based on the data stream identifier and the port example: ddt-5001_ds1
◆ GetAvailableSpace()
const uint64_t DdtMemoryManager::GetAvailableSpace |
( |
| ) |
|
|
protected |
Reads the available space on /dev/shm using the linux df command.
- Returns
- Available space in bytes.
create the linux command example: df /dev/shm | grep /dev/shm 2>&1
◆ GetMaxPossibleBufferSize()
int32_t DdtMemoryManager::GetMaxPossibleBufferSize |
( |
const int32_t |
max_data_sample_size | ) |
|
Computes the maximum possible number of buffer elements.
- Parameters
-
max_data_sample_size | The maximum data sample size. |
- Returns
- The maximum possible number of buffer elements.
The documentation for this class was generated from the following files: