HTGS
v2.0
The Hybrid Task Graph Scheduler
|
Spawns threads and binds them to the appropriate ITask within a TaskGraph. More...
#include <htgs/api/TaskGraphRuntime.hpp>
Public Member Functions | |
TaskGraphRuntime (AnyTaskGraphConf *graph) | |
Constructs a Runtime for a TaskGraph. More... | |
~TaskGraphRuntime () | |
Destructor. | |
void | waitForRuntime () |
Waits for the Runtime to finish executing. More... | |
void | executeAndWaitForRuntime () |
Executes the Runtime and then waits for it to finish processing. | |
void | terminateAll () |
Terminates the Runtime. More... | |
void | executeRuntime () |
Executes the Runtime. | |
Private Attributes | |
std::list< std::thread * > | threads |
A list of all threads spawned for the Runtime. | |
AnyTaskGraphConf * | graph |
The TaskGraph associated with the Runtime. | |
std::list< TaskManagerThread * > | runtimeThreads |
The list of TaskManagers bound to each thread. | |
bool | executed |
Whether the Runtime has been executed. | |
Spawns threads and binds them to the appropriate ITask within a TaskGraph.
Each thread is bound to a separate ITask instance. If an ITask has more than one thread associated with it, then the Runtime will create a deep copy of the ITask, which is bound to the thread. This means that each thread has a different ITask instance.
This process is done for every ITask in the TaskGraph that the Runtime is responsible for.
If an ITask is an ExecutionPipeline, then the thread responsible for the ExecutionPipeline will create additional TaskGraphRuntimes, one for each TaskGraph within the ExecutionPipeline.
A Runtime can be executed asynchronously with executeRuntime(), allowing for interaction with the main TaskGraph to submit/receive data to/from the TaskGraph.
To wait for the Runtime to finish processing all of the data for a TaskGraph, use waitForRuntime(). Be sure to indicate that the input data stream for the graph is closing prior to calling waitForRuntime() (see below).
To execute and wait for the Runtime, use executeAndWaitForRuntime(). If data is being produced for the task graph, then the TaskGraph::finishedProducingData function must be called prior to waiting for the runtime in order for the task graph to know that the input to the graph has finished and the tasks processing that input can be notified.
Example Usage:
|
inline |
Constructs a Runtime for a TaskGraph.
graph | the graph the Runtime is representing |
|
inline |
Terminates the Runtime.
This function will only mark the thread to be terminated, but will only end once the thread has finished processing its last data. Will not terminate threads that are in a WAIT state.
|
inline |
Waits for the Runtime to finish executing.
Should call execute first, otherwise this function will return immediately.