Code_TYMPAN  4.4.0
Industrial site acoustic simulation
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
OThreadPool Class Reference

Slave threads collection. More...

#include <threading.h>

Inheritance diagram for OThreadPool:
Inheritance graph
[legend]
Collaboration diagram for OThreadPool:
Collaboration graph
[legend]

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
 

Detailed Description

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; }

Author
Projet_Tympan

Definition at line 224 of file threading.h.

Constructor & Destructor Documentation

◆ OThreadPool() [1/2]

OThreadPool::OThreadPool ( unsigned int  slaves)

Build a threads collection and allocate "slaves" thread.

Definition at line 101 of file threading.cpp.

◆ ~OThreadPool() [1/2]

OThreadPool::~OThreadPool ( )
virtual

Destructor.

Definition at line 111 of file threading.cpp.

◆ OThreadPool() [2/2]

OThreadPool::OThreadPool ( unsigned int  slaves)

Build a threads collection and allocate "slaves" thread.

◆ ~OThreadPool() [2/2]

virtual OThreadPool::~OThreadPool ( )
virtual

Destructor.

Member Function Documentation

◆ begin() [1/2]

void OThreadPool::begin ( unsigned int  count)

Begin solver.

Definition at line 165 of file threading.cpp.

Here is the caller graph for this function:

◆ begin() [2/2]

void OThreadPool::begin ( unsigned int  count)

◆ end() [1/2]

bool OThreadPool::end ( )

End solver.

Definition at line 183 of file threading.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ end() [2/2]

bool OThreadPool::end ( )

◆ getCount() [1/2]

unsigned int OThreadPool::getCount ( ) const

Return the counter.

Definition at line 159 of file threading.cpp.

Here is the caller graph for this function:

◆ getCount() [2/2]

unsigned int OThreadPool::getCount ( ) const

◆ getTotalCount() [1/2]

unsigned int OThreadPool::getTotalCount ( ) const

Return the total number of tasks.

Definition at line 153 of file threading.cpp.

Here is the caller graph for this function:

◆ getTotalCount() [2/2]

unsigned int OThreadPool::getTotalCount ( ) const

◆ push() [1/2]

void OThreadPool::push ( OTask task)
virtual

Add a task to the queue.

Definition at line 142 of file threading.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ push() [2/2]

virtual void OThreadPool::push ( OTask task)
virtual

◆ startPool() [1/2]

void OThreadPool::startPool ( )

Definition at line 173 of file threading.cpp.

Here is the caller graph for this function:

◆ startPool() [2/2]

void OThreadPool::startPool ( )

◆ stop() [1/2]

void OThreadPool::stop ( )
protected

Cancel the pending tasks.

Definition at line 198 of file threading.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stop() [2/2]

void OThreadPool::stop ( )
protected

Cancel the pending tasks.

Friends And Related Function Documentation

◆ OSlaveThread

OSlaveThread
friend

Definition at line 278 of file threading.h.

Member Data Documentation

◆ _counter

unsigned int OThreadPool::_counter
protected

Total number of ended tasks.

Definition at line 276 of file threading.h.

◆ _tasks

std::queue< LPOTask > OThreadPool::_tasks
protected

Tasks queue.

Definition at line 270 of file threading.h.

◆ _totalCount

unsigned int OThreadPool::_totalCount
protected

Total number of tasks to run.

Definition at line 273 of file threading.h.


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