Documentation of UrbanFireXDT
Documentation of UrbanFireXDT
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
CUControllerThreadGroupManager Class Reference

#include <worker_threads.hpp>

Public Member Functions

 CUControllerThreadGroupManager (const std::vector< ControlUnit * > *subsection=NULL)
 
 ~CUControllerThreadGroupManager ()
 
void startAllWorkerThreads ()
 
void stopAllWorkerThreads ()
 
void executeOneStep (unsigned long ts)
 
bool waitForWorkersToFinish ()
 
ControlUnitgetNextControlUnit ()
 

Friends

class CUControllerWorkerThread
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ 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
subsectionIf 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 ( )

Member Function Documentation

◆ 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
tsThe current time step (required for calling ControlUnit::compute_next_value())
dayOfWeek_lThe day of the week (left aligned) of the current time step (required for calling ControlUnit::compute_next_value())
hourOfDay_lThe hour of the day (left aligned) of the current time step (required for calling ControlUnit::compute_next_value())

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

Friends And Related Symbol Documentation

◆ CUControllerWorkerThread

friend class CUControllerWorkerThread
friend

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