#include <worker_threads.hpp>
This class represents one group of threads of the class CUControllerWorkerThread. It provides functionality for creating and managing all existing thread instances.
This class is not thread-safe.
◆ CUControllerThreadGroupManager()
| CUControllerThreadGroupManager::CUControllerThreadGroupManager |
( |
const std::vector< ControlUnit * > * |
subsection = NULL | ) |
|
This function initializes the a new instance of the thread group manager. It initializes the threads internally.
- Parameters
-
| subsection | If the thread group should only be started for a subset of the available control units, the list of control units must be passed by this argument. Defaults to NULL, meaning that the group manager should handle all control units. |
◆ ~CUControllerThreadGroupManager()
| CUControllerThreadGroupManager::~CUControllerThreadGroupManager |
( |
| ) |
|
◆ executeOneStep()
| void CUControllerThreadGroupManager::executeOneStep |
( |
unsigned long |
ts | ) |
|
This method notifies the worker threads to start working. This means that the threads will start to call ControlUnit::compute_next_value() iteratively for all control units connected.
- Parameters
-
◆ getNextControlUnit()
| ControlUnit * CUControllerThreadGroupManager::getNextControlUnit |
( |
| ) |
|
This function returns a pointer to the next control unit in the list of all control units for which ControlUnit::compute_next_value() has not been computed yet. It is thread safe and should be called by the CUContollerWorkerThread instances. Relevant for the case of using work stealing.
- Returns
- A pointer to a control unit or null, if there is not control unit left
◆ startAllWorkerThreads()
| void CUControllerThreadGroupManager::startAllWorkerThreads |
( |
| ) |
|
This function starts all worker threads. This means that the threads are forked and start to idle and with for tasks. If called multiple times, it does not do anything.
◆ stopAllWorkerThreads()
| void CUControllerThreadGroupManager::stopAllWorkerThreads |
( |
| ) |
|
This function stops all worker threads. It stops all threads and joins them again. If called multiple times, it does not do anything.
◆ waitForWorkersToFinish()
| bool CUControllerThreadGroupManager::waitForWorkersToFinish |
( |
| ) |
|
This function waits until all workers are finished with executed their task, that has been started with ExecuteOneStep().
- Returns
- true, if no error happend during the simulation, or false, if an error occured and the simulation must be stopped.
◆ CUControllerWorkerThread
The documentation for this class was generated from the following files: