#include <ThreadPool.h>

Public Member Functions | |
| ThreadPool (int maxNumThreads) | |
| virtual | ~ThreadPool () |
| int | dispatch (int id, ThreadPoolJob &f) |
| void | waitAll () |
| int | getNumThreads () |
| returns number of threads which it holds | |
Protected Attributes | |
| int | _maxNumThreads |
| std::vector< thread * > | threads |
| std::vector< WorkerState * > | workerstates |
| std::vector< condition * > | cond1 |
| std::vector< condition * > | cond2 |
| std::vector< mutex * > | mtx1 |
| std::vector< mutex * > | mtx2 |
Definition at line 68 of file ThreadPool.h.
| ThreadPool::ThreadPool | ( | int | maxNumThreads | ) |
Definition at line 54 of file ThreadPool.cpp.
References _maxNumThreads, cond1, cond2, mtx1, mtx2, threads, and workerstates.
| ThreadPool::~ThreadPool | ( | ) | [virtual] |
Definition at line 99 of file ThreadPool.cpp.
References _maxNumThreads, cond1, cond2, mtx1, mtx2, threads, and workerstates.
| int ThreadPool::dispatch | ( | int | id, | |
| ThreadPoolJob & | f | |||
| ) |
Takes thread with id from the pool, and executes the function object within it.
Returns 0 if thread with id i is available, otherwise -1.
Definition at line 83 of file ThreadPool.cpp.
References cond1, cond2, mtx1, and workerstates.
Referenced by MultiThreadSimEngine::advanceSeveralStepsWithinACycle(), MTDistributedCycledAnalogMsgDispatcher::dispatchDelayerCycledIncomingAnalogMsgs(), MultiThreadSimEngine::finalizeCycle(), MultiThreadSimEngine::initialize(), MTDistributedIncomingSpikeScheduler::processMPIInputSpikeBuffers(), and MultiThreadSimEngine::reset().
| void ThreadPool::waitAll | ( | ) |
Blocks until all the busy threads are finished.
Definition at line 92 of file ThreadPool.cpp.
References _maxNumThreads, and mtx2.
Referenced by MultiThreadSimEngine::advanceSeveralStepsWithinACycle(), MTDistributedCycledAnalogMsgDispatcher::dispatchDelayerCycledIncomingAnalogMsgs(), MultiThreadSimEngine::finalizeCycle(), MultiThreadSimEngine::initialize(), MTDistributedIncomingSpikeScheduler::processMPIInputSpikeBuffers(), and MultiThreadSimEngine::reset().
| int ThreadPool::getNumThreads | ( | ) | [inline] |
returns number of threads which it holds
Definition at line 88 of file ThreadPool.h.
References _maxNumThreads.
Referenced by MTDistributedCycledAnalogMsgDispatcher::dispatchDelayerCycledIncomingAnalogMsgs().
int ThreadPool::_maxNumThreads [protected] |
Definition at line 93 of file ThreadPool.h.
Referenced by getNumThreads(), ThreadPool(), waitAll(), and ~ThreadPool().
std::vector<thread*> ThreadPool::threads [protected] |
std::vector<WorkerState*> ThreadPool::workerstates [protected] |
Definition at line 96 of file ThreadPool.h.
Referenced by dispatch(), ThreadPool(), and ~ThreadPool().
std::vector<condition*> ThreadPool::cond1 [protected] |
Definition at line 97 of file ThreadPool.h.
Referenced by dispatch(), ThreadPool(), and ~ThreadPool().
std::vector<condition*> ThreadPool::cond2 [protected] |
Definition at line 98 of file ThreadPool.h.
Referenced by dispatch(), ThreadPool(), and ~ThreadPool().
std::vector<mutex*> ThreadPool::mtx1 [protected] |
Definition at line 99 of file ThreadPool.h.
Referenced by dispatch(), ThreadPool(), and ~ThreadPool().
std::vector<mutex*> ThreadPool::mtx2 [protected] |
Definition at line 100 of file ThreadPool.h.
Referenced by ThreadPool(), waitAll(), and ~ThreadPool().
1.5.5