|
hoshi-lang dev
Yet another programming language
|
#include <codegenTaskDispatcher.hpp>
Public Member Functions | |
| CodegenTaskDispatcher (size_t threadCount=0) | |
| ~CodegenTaskDispatcher () | |
| CodegenTaskDispatcher (const CodegenTaskDispatcher &)=delete | |
| CodegenTaskDispatcher & | operator= (const CodegenTaskDispatcher &)=delete |
| void | dispatch (std::function< void()> task) |
| Dispatch a task to the thread pool. | |
| void | wait () |
| Wait for all dispatched tasks to complete. | |
Private Member Functions | |
| void | workerLoop () |
Private Attributes | |
| std::vector< std::thread > | workers |
| std::queue< std::function< void()> > | taskQueue |
| std::mutex | queueMutex |
| std::condition_variable | queueCondition |
| std::mutex | waitMutex |
| std::condition_variable | waitCondition |
| std::atomic< size_t > | activeTasks {0} |
| std::atomic< bool > | stop {false} |
Definition at line 18 of file codegenTaskDispatcher.hpp.
|
explicit |
Definition at line 9 of file codegenTaskDispatcher.cpp.
References CodegenTaskDispatcher::workerLoop(), and CodegenTaskDispatcher::workers.

Definition at line 19 of file codegenTaskDispatcher.cpp.
References CodegenTaskDispatcher::queueCondition, CodegenTaskDispatcher::queueMutex, CodegenTaskDispatcher::stop, and CodegenTaskDispatcher::workers.
|
delete |
| void dispatch | ( | std::function< void()> | task | ) |
Dispatch a task to the thread pool.
| task | The task to execute. |
Definition at line 32 of file codegenTaskDispatcher.cpp.
References CodegenTaskDispatcher::activeTasks, CodegenTaskDispatcher::queueCondition, CodegenTaskDispatcher::queueMutex, and CodegenTaskDispatcher::taskQueue.
Referenced by LLVMCodegen::generate().

|
delete |
| void wait | ( | ) |
Wait for all dispatched tasks to complete.
Definition at line 41 of file codegenTaskDispatcher.cpp.
References CodegenTaskDispatcher::activeTasks, CodegenTaskDispatcher::waitCondition, and CodegenTaskDispatcher::waitMutex.
Referenced by LLVMCodegen::generate().

|
private |
Definition at line 46 of file codegenTaskDispatcher.cpp.
References CodegenTaskDispatcher::activeTasks, CodegenTaskDispatcher::queueCondition, CodegenTaskDispatcher::queueMutex, CodegenTaskDispatcher::stop, CodegenTaskDispatcher::taskQueue, CodegenTaskDispatcher::waitCondition, and CodegenTaskDispatcher::waitMutex.
Referenced by CodegenTaskDispatcher::CodegenTaskDispatcher().

|
private |
Definition at line 50 of file codegenTaskDispatcher.hpp.
Referenced by CodegenTaskDispatcher::dispatch(), CodegenTaskDispatcher::wait(), and CodegenTaskDispatcher::workerLoop().
|
private |
Definition at line 45 of file codegenTaskDispatcher.hpp.
Referenced by CodegenTaskDispatcher::dispatch(), CodegenTaskDispatcher::workerLoop(), and CodegenTaskDispatcher::~CodegenTaskDispatcher().
|
private |
Definition at line 44 of file codegenTaskDispatcher.hpp.
Referenced by CodegenTaskDispatcher::dispatch(), CodegenTaskDispatcher::workerLoop(), and CodegenTaskDispatcher::~CodegenTaskDispatcher().
|
private |
Definition at line 51 of file codegenTaskDispatcher.hpp.
Referenced by CodegenTaskDispatcher::workerLoop(), and CodegenTaskDispatcher::~CodegenTaskDispatcher().
|
private |
Definition at line 42 of file codegenTaskDispatcher.hpp.
Referenced by CodegenTaskDispatcher::dispatch(), and CodegenTaskDispatcher::workerLoop().
|
private |
Definition at line 48 of file codegenTaskDispatcher.hpp.
Referenced by CodegenTaskDispatcher::wait(), and CodegenTaskDispatcher::workerLoop().
|
private |
Definition at line 47 of file codegenTaskDispatcher.hpp.
Referenced by CodegenTaskDispatcher::wait(), and CodegenTaskDispatcher::workerLoop().
|
private |
Definition at line 41 of file codegenTaskDispatcher.hpp.
Referenced by CodegenTaskDispatcher::CodegenTaskDispatcher(), and CodegenTaskDispatcher::~CodegenTaskDispatcher().