14 #ifndef LLVM_SUPPORT_THREAD_POOL_H 15 #define LLVM_SUPPORT_THREAD_POOL_H 17 #include "llvm/Config/llvm-config.h" 23 #include <condition_variable> 39 using TaskTy = std::function<void()>;
57 std::bind(std::forward<Function>(
F), std::forward<Args>(ArgList)...);
58 return asyncImpl(std::move(Task));
63 template <
typename Function>
65 return asyncImpl(std::forward<Function>(
F));
75 std::shared_future<void> asyncImpl(
TaskTy F);
78 std::vector<llvm::thread> Threads;
81 std::queue<PackagedTaskTy> Tasks;
85 std::condition_variable QueueCondition;
88 std::mutex CompletionLock;
89 std::condition_variable CompletionCondition;
92 std::atomic<unsigned> ActiveThreads;
94 #if LLVM_ENABLE_THREADS // avoids warning for unused variable 101 #endif // LLVM_SUPPORT_THREAD_POOL_H This class represents lattice values for constants.
std::packaged_task< void()> PackagedTaskTy
std::function< void()> TaskTy
std::shared_future< void > async(Function &&F, Args &&... ArgList)
Asynchronous submission of a task to the pool.
~ThreadPool()
Blocking destructor: the pool will wait for all the threads to complete.
A ThreadPool for asynchronous parallel execution on a defined number of threads.
std::shared_future< void > async(Function &&F)
Asynchronous submission of a task to the pool.
ThreadPool()
Construct a pool with the number of threads found by hardware_concurrency().
void wait()
Blocking wait for all the threads to complete and the queue to be empty.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.