class ThreadPool

Declaration

class ThreadPool { /* full declaration omitted */ };

Description

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.

Declared at: llvm/include/llvm/Support/ThreadPool.h:36

Method Overview

  • public ThreadPool()
  • public ThreadPool(unsigned int ThreadCount)
  • public template <typename Function, typename... Args>inline std::shared_future<void> async(Function && F, Args &&... ArgList)
  • public template <typename Function>inline std::shared_future<void> async(Function && F)
  • public void wait()
  • public ~ThreadPool()

Methods

ThreadPool()

Description

Construct a pool with the number of threads found by hardware_concurrency().

Declared at: llvm/include/llvm/Support/ThreadPool.h:43

ThreadPool(unsigned int ThreadCount)

Description

Construct a pool of \p ThreadCount threads

Declared at: llvm/include/llvm/Support/ThreadPool.h:46

Parameters

unsigned int ThreadCount

template <typename Function, typename... Args>
inline std::shared_future<void> async(
    Function&& F,
    Args&&... ArgList)

Description

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.

Declared at: llvm/include/llvm/Support/ThreadPool.h:54

Templates

Function
Args

Parameters

Function&& F
Args&&... ArgList

template <typename Function>
inline std::shared_future<void> async(
    Function&& F)

Description

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.

Declared at: llvm/include/llvm/Support/ThreadPool.h:63

Templates

Function

Parameters

Function&& F

void wait()

Description

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.

Declared at: llvm/include/llvm/Support/ThreadPool.h:69

~ThreadPool()

Description

Blocking destructor: the pool will wait for all the threads to complete.

Declared at: llvm/include/llvm/Support/ThreadPool.h:49