![]() |
HTGS
v2.0
The Hybrid Task Graph Scheduler
|
Describes memory allocated by a MemoryManager to manage shared memory across multiple ITask. More...
#include <htgs/api/MemoryData.hpp>
Public Member Functions | |
MemoryData (std::shared_ptr< IMemoryAllocator< T >> allocator, std::weak_ptr< Connector< MemoryData< T >>> memoryManagerConnector, std::string memoryManagerName, MMType type) | |
Creates MemoryData with the specified IMemoryAllocator. More... | |
~MemoryData () | |
Destructor that releases IMemoryAllocator memory. | |
void | releaseMemory () |
Gets the address of the memory manager that allocated this memory data. More... | |
void | setPipelineId (size_t id) |
Sets the pipelineId associated with the MemoryManager that allocated the memory. More... | |
size_t | getPipelineId () const |
Gets the pipelineId associated with the MemoryManager that allocated the memory. More... | |
size_t | getSize () const |
Gets the size of the memory that was allocated. More... | |
void | setMemoryReleaseRule (IMemoryReleaseRule *rule) |
Sets the memory release rule. More... | |
IMemoryReleaseRule * | getMemoryReleaseRule () const |
Gets the memory release rule associated with the memory data. More... | |
bool | canReleaseMemory () |
Checks whether the memory can be recycled/released by the MemoryManager. More... | |
void | memoryUsed () |
Updates the state of the memory when it is received by the MemoryManager. More... | |
void | memAlloc () |
Allocates the memory that this MemoryData is using. More... | |
T * | get () |
Gets the memory that this MemoryData is managing. More... | |
const T & | get (size_t idx) const |
Gets the data that is held by this memory data at the specified index. More... | |
T & | get (size_t idx) |
Gets the data that is held by this memory data at the specified index. More... | |
const T & | operator[] (size_t idx) const |
Gets the value for memory at index. More... | |
T & | operator[] (size_t idx) |
Gets the value for memory at index. More... | |
void | memFree () |
Frees the memory that this MemoryData is managing. More... | |
MMType | getType () const |
Gets the type of memory that is associated with the memory manager. More... | |
MemoryData< T > * | copy () |
Creates a copy of this MemoryData. More... | |
void | memAlloc (size_t size) |
Allocates the memory that this memory data is managed with the specified size. More... | |
const std::string & | getMemoryManagerName () const |
Gets the memory manager name. More... | |
![]() | |
IData () | |
Constructs an IData with default ordering = 0. | |
IData (size_t order) | |
Constructs IData with integer ordering. More... | |
virtual | ~IData () |
Destructor. | |
bool | operator() (const std::shared_ptr< IData > p1, const std::shared_ptr< IData > p2) const |
Compares two IData pointers for ordering. More... | |
virtual bool | compare (const std::shared_ptr< IData > p2) const |
Virtual IData comparison function, can be used for custom ordering. More... | |
size_t | getOrder () const |
Gets the order of this IData. More... | |
Private Attributes | |
MMType | type |
The type of memory manager. | |
std::string | memoryManagerName |
The name of the memory manager that allocated the memory. | |
std::weak_ptr< Connector< MemoryData< T > > > | memoryManagerConnector |
The pointer to the connector that owns this memory. | |
size_t | pipelineId |
The pipelineId associated with where this memory was managed. | |
T * | memory |
The memory. | |
size_t | size |
The size of the memory (in elements) | |
IMemoryReleaseRule * | memoryReleaseRule |
The memory release rule associated with the memory. | |
std::shared_ptr< IMemoryAllocator< T > > | allocator |
The allocator associated with the memory. | |
Describes memory allocated by a MemoryManager to manage shared memory across multiple ITask.
Provides mechanisms for allocation, freeing, and memory release strategies associated with memory. Using these mechanisms the MemoryManager can process the memory and recycle it only when the IMemoryReleaseRule indicates it is ready to be released.
In order to properly share this data, it should be forwarded along with other IData until the ITask responsible for releasing the data back to its MemoryManager is called.
To receive memory from the MemoryManager use ITask::getMemory. To send memory to the MemoryManager use ITask::releaseMemory
Use htgs::m_data_t<Type> from <htgs/types/Types.hpp> when handling MemoryData to reduce code size.
Example Usage:
Example attaching MemoryManager:
T | the type of memory to be held by the MemoryData, this will automatically be converted to a pointer type |
|
inline |
Creates MemoryData with the specified IMemoryAllocator.
allocator | the memory allocator |
memoryManagerConnector | the pointer to the connector that owns this memory |
memoryManagerName | the name of the memory manager that allocated this memory |
type | the type of the memory manager that allocated this memory |
|
inline |
Checks whether the memory can be recycled/released by the MemoryManager.
|
inline |
Creates a copy of this MemoryData.
|
inline |
Gets the memory that this MemoryData is managing.
|
inline |
Gets the data that is held by this memory data at the specified index.
idx | the index |
|
inline |
Gets the data that is held by this memory data at the specified index.
idx | the index |
|
inline |
Gets the memory manager name.
|
inline |
Gets the memory release rule associated with the memory data.
|
inline |
Gets the pipelineId associated with the MemoryManager that allocated the memory.
|
inline |
Gets the size of the memory that was allocated.
|
inline |
Gets the type of memory that is associated with the memory manager.
|
inline |
Allocates the memory that this MemoryData is using.
|
inline |
Allocates the memory that this memory data is managed with the specified size.
size | the number of elements to allocate |
|
inline |
Frees the memory that this MemoryData is managing.
|
inline |
Updates the state of the memory when it is received by the MemoryManager.
|
inline |
Gets the value for memory at index.
idx | the index |
|
inline |
Gets the value for memory at index.
idx | the index |
|
inline |
Gets the address of the memory manager that allocated this memory data.
|
inline |
Sets the memory release rule.
rule | the new rule that manages the memory |
|
inline |
Sets the pipelineId associated with the MemoryManager that allocated the memory.
id | the pipielineId |