A very simple thread pool for use by Surface. More...
#include <ThreadPool.h>
Classes | |
struct | Task |
Public Member Functions | |
ThreadPool (unsigned int maxThreads=0) | |
virtual | ~ThreadPool () |
void | ShowProgress (const std::string &title) |
void | Finish () |
Wait for all threads to complete before returning. More... | |
template<class F , class... A> | |
void | AddTask (F func, A...args) |
Add task with arguments. More... | |
template<class T , class M , class... A> | |
void | AddMemberTask (T *obj, M meth, A...args) |
Add member function task, with arguments. More... | |
Protected Types | |
typedef std::function< void(void)> | func_t |
The type of the user's worker functions. More... | |
Protected Member Functions | |
void | AddTaskHelper (func_t func) |
Static Protected Member Functions | |
static void * | WorkerFunc (void *arg) |
Protected Attributes | |
unsigned int | fMaxThreads |
pthread_mutex_t | fTasksLock |
std::deque< func_t > | fTasks |
Actually, this is protecting fNumLiveThreads. More... | |
pthread_mutex_t | fThreadsLock |
std::vector< pthread_t > | fThreads |
All threads we ever created. More... | |
unsigned int | fNumLiveThreads |
Number of threads that are running. More... | |
pthread_mutex_t | fProgressLock |
Protects fTasksCompleted and fTotalTasks too. More... | |
int | fTasksCompleted |
int | fTotalTasks |
How many tasks have we ever seen? More... | |
Progress * | fProgress |
A very simple thread pool for use by Surface.
With great power comes great responsibility. Use caution on the grid or on shared interactive machines before you get yelled at or banned.
Definition at line 17 of file ThreadPool.h.
|
protected |
The type of the user's worker functions.
Use std::bind etc to pass arguments
Definition at line 43 of file ThreadPool.h.
|
explicit |
maxThreads | Maximum number of threads to use at one time. If unspecified, uses number of cores in machine. Use great caution on the grid or on shared interactive machines. |
Definition at line 11 of file ThreadPool.cxx.
|
virtual |
Definition at line 25 of file ThreadPool.cxx.
|
inline |
|
inline |
|
protected |
Definition at line 92 of file ThreadPool.cxx.
void ana::ThreadPool::Finish | ( | ) |
Wait for all threads to complete before returning.
Definition at line 44 of file ThreadPool.cxx.
void ana::ThreadPool::ShowProgress | ( | const std::string & | title | ) |
Definition at line 38 of file ThreadPool.cxx.
|
staticprotected |
Definition at line 57 of file ThreadPool.cxx.
|
protected |
Definition at line 50 of file ThreadPool.h.
|
protected |
Number of threads that are running.
Definition at line 60 of file ThreadPool.h.
|
protected |
Definition at line 66 of file ThreadPool.h.
|
protected |
Protects fTasksCompleted and fTotalTasks too.
Definition at line 63 of file ThreadPool.h.
|
protected |
Actually, this is protecting fNumLiveThreads.
Definition at line 55 of file ThreadPool.h.
|
protected |
Definition at line 64 of file ThreadPool.h.
|
protected |
Definition at line 54 of file ThreadPool.h.
|
protected |
All threads we ever created.
Definition at line 59 of file ThreadPool.h.
|
protected |
Definition at line 58 of file ThreadPool.h.
|
protected |
How many tasks have we ever seen?
Definition at line 65 of file ThreadPool.h.