HTGS
v2.0
The Hybrid Task Graph Scheduler
|
Manages a TaskManager that is bound to a thread for execution. More...
#include <htgs/task/AnyTaskManager.hpp>
Public Member Functions | |
TaskManagerThread (size_t threadId, AnyTaskManager *task, std::shared_ptr< std::atomic_size_t > numThreads, std::condition_variable *taskGraphInitializeCond, std::mutex *taskGraphInitializeMutex) | |
Constructs a TaskManagerThread with a specified AnyTaskManager and atomic number of threads that is shared among all other threads that operate with a copy of the same AnyTaskManager. More... | |
~TaskManagerThread () | |
Destructor. | |
int | run () |
Executes the task until the underlying Task has been terminated. More... | |
size_t | getThreadsRemaining () |
Gets the number of threads remaining. More... | |
void | decrementNumThreadsRemaining () |
Decrements the number of threads remaining by one. | |
bool | decrementAndCheckNumThreadsRemaining () |
Decrements the number of threads and checks if there are no threads remaining in a single operation. More... | |
bool | hasNoThreadsRemaining () |
Checks if there are no more threads executing a Task. More... | |
void | terminate () |
Indicates that the thread is ready to be terminated. More... | |
Private Attributes | |
volatile bool | terminated |
Whether the thread is ready to be terminated or not. | |
std::shared_ptr< std::atomic_size_t > | numThreads |
The number of total threads managing the TaskManager. | |
AnyTaskManager * | task |
The TaskManager that is called from the thread. | |
size_t | numThreadsAfterDecrement |
std::condition_variable * | taskGraphInitializeCond |
The condition variable that is used by the owner task graph for checking if all tasks have been initialized. | |
std::mutex * | taskGraphInitializeMutex |
The mutex used to notify the task has been initialized. | |
Manages a TaskManager that is bound to a thread for execution.
A Runtime will spawn a thread and bind it to the run function within this class. If a Task has more than one threads associated with it, then this class is duplicated one per thread, each with a separate copy of the original TaskManager.
|
inline |
Constructs a TaskManagerThread with a specified AnyTaskManager and atomic number of threads that is shared among all other threads that operate with a copy of the same AnyTaskManager.
threadId | the thread Id for the task |
task | the task the thread is associated with |
numThreads | the number of threads that a task contains |
taskGraphInitializeCond | The initialization condition variable used to indicate that the task has initialized |
taskGraphInitializeMutex | The mutex used to notify the task has been initialized |
|
inline |
Decrements the number of threads and checks if there are no threads remaining in a single operation.
TRUE | if there are no more threads executing a Task |
FALSE | if there are threads executing a Task |
|
inline |
Gets the number of threads remaining.
|
inline |
Checks if there are no more threads executing a Task.
TRUE | if there are no more threads executing a Task |
FALSE | if there are threads executing a Task |
|
inline |
Executes the task until the underlying Task has been terminated.
0 | Completed successfully |
|
inline |
Indicates that the thread is ready to be terminated.
This function will mark the thread is ready to be terminated, but will only end once the thread has finished processing its last data.