Number5
Visualisierung 2 Project - Florian Schober (0828151, f.schober@live.com), Andreas Walch (0926780, walch.andreas89@gmail.com)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
TaskManager Class Reference

#include <TaskManager.hpp>

Public Member Functions

 TaskManager (Application *app)
 
 ~TaskManager ()
 
template<typename T >
void schedule (T fnc)
 
template<typename T , typename TEvent >
void schedule (T fnc, TEvent *event=nullptr)
 

Private Member Functions

void worker (BOOL *keepAlive)
 

Private Attributes

concurrency::concurrent_queue
< function< void()> > 
m_taskqueue
 A queue of tasks that needs to be executed. More...
 
vector< BOOL > m_threadKeepAlive
 A a bool for each working-thread that tells it wheter or not to stay alive. More...
 
auto_reset_event m_threadHasTodo
 An event that tells workers wheter or not there is a task. More...
 
vector< thread > m_threads
 The thread object for all worker-threads. More...
 

Detailed Description

Manages the parallel execution of tasks. Tasks can be registered to be run in other threads (worker-threads).

Definition at line 60 of file TaskManager.hpp.

Constructor & Destructor Documentation

Constructs a TaskManager-instance. N worker-threads will automatically be created, where N is the number of threadpool-size given by the config-file.

Parameters
appThe global application

Definition at line 72 of file TaskManager.cpp.

Destructs a TaskManager-instance. All worker-threads will be signalled to stop. This call blocks until all worker-threads are terminated.

Definition at line 87 of file TaskManager.cpp.

Member Function Documentation

void schedule ( fnc)
inline

Schedule a task. The given task will be executed in another thread.

Parameters
fncAn object that provides the ()-operator (which will be used to 'execute' the task)

Definition at line 86 of file TaskManager.hpp.

void schedule ( fnc,
TEvent *  event = nullptr 
)
inline

Schedule a task. The given task will be executed in another thread.

Parameters
fncAn object that provides the ()-operator (which will be used to 'execute' the task)
eventIf event is nullptr it is ignored. If not, the 'signal' method (with no parameters) will be called on it after the task was executed.

Definition at line 97 of file TaskManager.hpp.

void worker ( BOOL *  keepAlive)
private

A woker-thread.

Parameters
keepAlivea pointer to a bool that tells the thread wheter or not to stay alive.

Definition at line 99 of file TaskManager.cpp.

Member Data Documentation

concurrency::concurrent_queue<function<void()> > m_taskqueue
private

A queue of tasks that needs to be executed.

Definition at line 62 of file TaskManager.hpp.

auto_reset_event m_threadHasTodo
private

An event that tells workers wheter or not there is a task.

Definition at line 64 of file TaskManager.hpp.

vector<BOOL> m_threadKeepAlive
private

A a bool for each working-thread that tells it wheter or not to stay alive.

Definition at line 63 of file TaskManager.hpp.

vector<thread> m_threads
private

The thread object for all worker-threads.

Definition at line 65 of file TaskManager.hpp.


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