|
LLVM
4.0.0
|
A ThreadPool for asynchronous parallel execution on a defined number of threads. More...
#include <ThreadPool.h>
Public Types | |
| using | VoidTy = void |
| using | TaskTy = std::function< void()> |
| using | PackagedTaskTy = std::packaged_task< void()> |
Public Member Functions | |
| ThreadPool () | |
| Construct a pool with the number of core available on the system (or whatever the value returned by std::thread::hardware_concurrency() is). More... | |
| ThreadPool (unsigned ThreadCount) | |
Construct a pool of ThreadCount threads. More... | |
| ~ThreadPool () | |
| Blocking destructor: the pool will wait for all the threads to complete. More... | |
| template<typename Function , typename... Args> | |
| std::shared_future< VoidTy > | async (Function &&F, Args &&...ArgList) |
| Asynchronous submission of a task to the pool. More... | |
| template<typename Function > | |
| std::shared_future< VoidTy > | async (Function &&F) |
| Asynchronous submission of a task to the pool. More... | |
| void | wait () |
| Blocking wait for all the threads to complete and the queue to be empty. More... | |
A ThreadPool for asynchronous parallel execution on a defined number of threads.
The pool keeps a vector of threads alive, waiting on a condition variable for some work to become available.
Definition at line 51 of file ThreadPool.h.
| using llvm::ThreadPool::PackagedTaskTy = std::packaged_task<void()> |
Definition at line 56 of file ThreadPool.h.
| using llvm::ThreadPool::TaskTy = std::function<void()> |
Definition at line 55 of file ThreadPool.h.
| using llvm::ThreadPool::VoidTy = void |
Definition at line 54 of file ThreadPool.h.
| ThreadPool::ThreadPool | ( | ) |
Construct a pool with the number of core available on the system (or whatever the value returned by std::thread::hardware_concurrency() is).
Definition at line 24 of file ThreadPool.cpp.
| ThreadPool::ThreadPool | ( | unsigned | ThreadCount | ) |
Construct a pool of ThreadCount threads.
Definition at line 26 of file ThreadPool.cpp.
| ThreadPool::~ThreadPool | ( | ) |
Blocking destructor: the pool will wait for all the threads to complete.
Definition at line 103 of file ThreadPool.cpp.
|
inline |
Asynchronous submission of a task to the pool.
The returned future can be used to wait for the task to finish and is non-blocking on destruction.
Definition at line 78 of file ThreadPool.h.
References F.
Referenced by llvm::ThinLTOCodeGenerator::run().
|
inline |
Asynchronous submission of a task to the pool.
The returned future can be used to wait for the task to finish and is non-blocking on destruction.
Definition at line 96 of file ThreadPool.h.
References F.
| void ThreadPool::wait | ( | ) |
Blocking wait for all the threads to complete and the queue to be empty.
It is an error to try to add new tasks while blocking on this call.
Definition at line 75 of file ThreadPool.cpp.
1.8.6