HTGS  v2.0
The Hybrid Task Graph Scheduler
htgs::IData Class Reference

Class to hold any type of data. More...

#include <htgs/api/IData.hpp>

Inheritance diagram for htgs::IData:
Inheritance graph
Collaboration diagram for htgs::IData:
Collaboration graph

Public Member Functions

 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

size_t order
 The ordering of the data (lowest first)
 

Detailed Description

Class to hold any type of data.

Defines custom types of data that is used for data entering/leaving task graphs. All task's input and output types must derive from IData. IData can store any type of data.

One common usage is to store MemoryData within IData to be passed between tasks and released later.

Ordering can be used to specify the order of a task's priority queue (lowest value is first).

(Optional) You can customize the ordering to your specifications by overriding the following function:

virtual bool compare(const std::shared_ptr<IData> p2) const

Example implementation:

class MatrixData : public htgs::IData {
public:
MatrixData(int order, double * matrix, int matrixSize) : IData(order), matrix(matrix), matrixSize(matrixSize)
{}
// (optional) Reverses the default ordering
virtual bool compare(const std::shared_ptr<IData> p2) const {
return this->getOrder() < p2.getOrder();
}
private:
double *matrix;
int matrixSize;
};
Note
Must define the USE_PRIORITY_QUEUE directive to enable custom ordering of data between tasks.

Constructor & Destructor Documentation

◆ IData()

htgs::IData::IData ( size_t  order)
inline

Constructs IData with integer ordering.

Parameters
orderthe order in which a task will process the data (lowest value is processed first)
Note
Must define the USE_PRIORITY_QUEUE directive to enable custom ordering between tasks.

Member Function Documentation

◆ compare()

virtual bool htgs::IData::compare ( const std::shared_ptr< IData p2) const
inlinevirtual

Virtual IData comparison function, can be used for custom ordering.

Compares the current IData with another IData to determine ordering. By default, uses the order to determine the ordering. The higher the order value, the higher the priority.

Parameters
p2the other compared IData
Returns
The ordering of two IData
Return values
TRUEp2 is ahead of this
FALSEthis is ahead of p2
Note
Must define the USE_PRIORITY_QUEUE directive to enable custom ordering between tasks.

◆ getOrder()

size_t htgs::IData::getOrder ( ) const
inline

Gets the order of this IData.

Returns
the order

◆ operator()()

bool htgs::IData::operator() ( const std::shared_ptr< IData p1,
const std::shared_ptr< IData p2 
) const
inline

Compares two IData pointers for ordering.

Parameters
p1the first IData
p2the second IData
Returns
the ordering of the values
Return values
TRUEif p2 is ahead of p1
FALSEif p1 is ahead of p2

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