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

Manages a TaskManager that is bound to a thread for execution. More...

#include <htgs/task/AnyTaskManager.hpp>

Collaboration diagram for htgs::TaskManagerThread:
Collaboration graph

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.
 
AnyTaskManagertask
 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.
 

Detailed Description

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.

Note
This class should only be called by the HTGS API

Constructor & Destructor Documentation

◆ TaskManagerThread()

htgs::TaskManagerThread::TaskManagerThread ( size_t  threadId,
AnyTaskManager task,
std::shared_ptr< std::atomic_size_t >  numThreads,
std::condition_variable *  taskGraphInitializeCond,
std::mutex *  taskGraphInitializeMutex 
)
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.

Parameters
threadIdthe thread Id for the task
taskthe task the thread is associated with
numThreadsthe number of threads that a task contains
taskGraphInitializeCondThe initialization condition variable used to indicate that the task has initialized
taskGraphInitializeMutexThe mutex used to notify the task has been initialized

Member Function Documentation

◆ decrementAndCheckNumThreadsRemaining()

bool htgs::TaskManagerThread::decrementAndCheckNumThreadsRemaining ( )
inline

Decrements the number of threads and checks if there are no threads remaining in a single operation.

Returns
whether there are no more threads executing the Task
Return values
TRUEif there are no more threads executing a Task
FALSEif there are threads executing a Task

◆ getThreadsRemaining()

size_t htgs::TaskManagerThread::getThreadsRemaining ( )
inline

Gets the number of threads remaining.

Returns
the number of threads remaining

◆ hasNoThreadsRemaining()

bool htgs::TaskManagerThread::hasNoThreadsRemaining ( )
inline

Checks if there are no more threads executing a Task.

Returns
whether there are no more threads executing the Task
Return values
TRUEif there are no more threads executing a Task
FALSEif there are threads executing a Task

◆ run()

int htgs::TaskManagerThread::run ( )
inline

Executes the task until the underlying Task has been terminated.

Returns
status code
Return values
0Completed successfully

◆ terminate()

void htgs::TaskManagerThread::terminate ( )
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.


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