|
Code_TYMPAN
4.4.0
Industrial site acoustic simulation
|
Slave threads collection. More...
#include <threading.h>


Public Member Functions | |
| OThreadPool (unsigned int slaves) | |
| Build a threads collection and allocate "slaves" thread. More... | |
| virtual | ~OThreadPool () |
| Destructor. More... | |
| virtual void | push (OTask *task) |
| Add a task to the queue. More... | |
| unsigned int | getTotalCount () const |
| Return the total number of tasks. More... | |
| unsigned int | getCount () const |
| Return the counter. More... | |
| void | begin (unsigned int count) |
| Begin solver. More... | |
| void | startPool () |
| bool | end () |
| End solver. More... | |
| OThreadPool (unsigned int slaves) | |
| Build a threads collection and allocate "slaves" thread. More... | |
| virtual | ~OThreadPool () |
| Destructor. More... | |
| virtual void | push (OTask *task) |
| unsigned int | getTotalCount () const |
| unsigned int | getCount () const |
| void | begin (unsigned int count) |
| void | startPool () |
| bool | end () |
Protected Member Functions | |
| void | stop () |
| Cancel the pending tasks. More... | |
| void | stop () |
| Cancel the pending tasks. More... | |
Protected Attributes | |
| std::queue< LPOTask > | _tasks |
| Tasks queue. More... | |
| unsigned int | _totalCount |
| Total number of tasks to run. More... | |
| unsigned int | _counter |
| Total number of ended tasks. More... | |
Friends | |
| class | OSlaveThread |
Slave threads collection.
This class define a slave threads collection which run tasks pending in a queue. A task is a simple object which contains the Task::main method. Simple example :
#include "threading.h"
class MyTask : public OTask { public: void main(void) { std::cout << "Hello world task!" << std::endl; } };
int main(int argc, char** argv) { OThreadPool pool(10); MyTask task; pool.push(task); ... task.wait(); return 0; }
Definition at line 224 of file threading.h.
| OThreadPool::OThreadPool | ( | unsigned int | slaves | ) |
Build a threads collection and allocate "slaves" thread.
Definition at line 101 of file threading.cpp.
|
virtual |
Destructor.
Definition at line 111 of file threading.cpp.
| OThreadPool::OThreadPool | ( | unsigned int | slaves | ) |
Build a threads collection and allocate "slaves" thread.
|
virtual |
Destructor.
| void OThreadPool::begin | ( | unsigned int | count | ) |
Begin solver.
Definition at line 165 of file threading.cpp.

| void OThreadPool::begin | ( | unsigned int | count | ) |
| bool OThreadPool::end | ( | ) |
End solver.
Definition at line 183 of file threading.cpp.


| bool OThreadPool::end | ( | ) |
| unsigned int OThreadPool::getCount | ( | ) | const |
Return the counter.
Definition at line 159 of file threading.cpp.

| unsigned int OThreadPool::getCount | ( | ) | const |
| unsigned int OThreadPool::getTotalCount | ( | ) | const |
Return the total number of tasks.
Definition at line 153 of file threading.cpp.

| unsigned int OThreadPool::getTotalCount | ( | ) | const |
|
virtual |
Add a task to the queue.
Definition at line 142 of file threading.cpp.


|
virtual |
| void OThreadPool::startPool | ( | ) |
| void OThreadPool::startPool | ( | ) |
|
protected |
Cancel the pending tasks.
Definition at line 198 of file threading.cpp.


|
protected |
Cancel the pending tasks.
|
friend |
Definition at line 278 of file threading.h.
|
protected |
Total number of ended tasks.
Definition at line 276 of file threading.h.
|
protected |
Tasks queue.
Definition at line 270 of file threading.h.
|
protected |
Total number of tasks to run.
Definition at line 273 of file threading.h.