13 #ifndef LLVM_SUPPORT_THREAD_POOL_H 14 #define LLVM_SUPPORT_THREAD_POOL_H 16 #include "llvm/Config/llvm-config.h" 22 #include <condition_variable> 38 using TaskTy = std::function<void()>;
56 std::bind(std::forward<Function>(
F), std::forward<Args>(ArgList)...);
57 return asyncImpl(std::move(Task));
62 template <
typename Function>
64 return asyncImpl(std::forward<Function>(
F));
74 std::shared_future<void> asyncImpl(
TaskTy F);
77 std::vector<llvm::thread> Threads;
80 std::queue<PackagedTaskTy> Tasks;
84 std::condition_variable QueueCondition;
87 std::mutex CompletionLock;
88 std::condition_variable CompletionCondition;
91 std::atomic<unsigned> ActiveThreads;
93 #if LLVM_ENABLE_THREADS // avoids warning for unused variable 100 #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.