HTGS  v2.0
The Hybrid Task Graph Scheduler
htgs::IMemoryReleaseRule Class Referenceabstract

Abstract class that describes when memory can be released/reused. More...

#include <htgs/api/IMemoryReleaseRule.hpp>

Collaboration diagram for htgs::IMemoryReleaseRule:
Collaboration graph

Public Member Functions

virtual ~IMemoryReleaseRule ()
 Destructor.
 
virtual void memoryUsed ()=0
 Pure virtual function to update the state of when memory has been used.
 
virtual bool canReleaseMemory ()=0
 Pure virtual function to indicate when memory can be released. More...
 

Detailed Description

Abstract class that describes when memory can be released/reused.

This class is used anytime memory is requested by an ITask from a MemoryManager. To receive memory use the function ITask::getMemory

IMemoryReleaseRule is attached to the MemoryData. The MemoryData, should be added to IData as data flows through a TaskGraphConf until the memory can be released with ITask::releaseMemory

When memory is released, the MemoryManager processes the memory by first updating the state with memoryUsed(), then if canReleaseMemory() returns true, the memory will be recycled.

Example Implementation:

class ReleaseCountRule : public htgs::IMemoryReleaseRule {
public:
ReleaseCountRule(int releaseCount) :
releaseCount(releaseCount) {}
virtual void memoryUsed() { releaseCount--; }
virtual bool canReleaseMemory() { return releaseCount == 0; }
private:
int releaseCount;
}

Example Usage:

class SampleTask : public ITask<Data1, Data2>
{
...
void executeTask(std::shared_ptr<Data1> data)
{
...
// Get memory from "memEdge" MemoryManager, and attach the ReleaseCount rule to the memory
htgs::m_data_t<double> mem = this->memGet<double>("memEdge", new ReleaseCountRule(4));
...
// Store the memory data to be passed along task graph
addResult(new Data2(mem));
}
...
};

Member Function Documentation

◆ canReleaseMemory()

virtual bool htgs::IMemoryReleaseRule::canReleaseMemory ( )
pure virtual

Pure virtual function to indicate when memory can be released.

Returns
whether memory can be released
Return values
TRUEif memory is ready to be released
FALSEif memory is not ready to be released

The documentation for this class was generated from the following file: