![]() |
Number5
Visualisierung 2 Project - Florian Schober (0828151, f.schober@live.com), Andreas Walch (0926780, walch.andreas89@gmail.com)
|
#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... | |
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.
TaskManager | ( | Application * | app | ) |
Constructs a TaskManager-instance. N worker-threads will automatically be created, where N is the number of threadpool-size given by the config-file.
app | The global application |
Definition at line 72 of file TaskManager.cpp.
~TaskManager | ( | ) |
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.
|
inline |
Schedule a task. The given task will be executed in another thread.
fnc | An object that provides the ()-operator (which will be used to 'execute' the task) |
Definition at line 86 of file TaskManager.hpp.
|
inline |
Schedule a task. The given task will be executed in another thread.
fnc | An object that provides the ()-operator (which will be used to 'execute' the task) |
event | If 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.
|
private |
A woker-thread.
keepAlive | a pointer to a bool that tells the thread wheter or not to stay alive. |
Definition at line 99 of file TaskManager.cpp.
|
private |
A queue of tasks that needs to be executed.
Definition at line 62 of file TaskManager.hpp.
|
private |
An event that tells workers wheter or not there is a task.
Definition at line 64 of file TaskManager.hpp.
|
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.
|
private |
The thread object for all worker-threads.
Definition at line 65 of file TaskManager.hpp.