LLVM 20.0.0git
Public Member Functions | List of all members
llvm::SingleThreadExecutor Class Reference

A non-threaded implementation. More...

#include "llvm/Support/ThreadPool.h"

Inheritance diagram for llvm::SingleThreadExecutor:
Inheritance graph
[legend]

Public Member Functions

 SingleThreadExecutor (ThreadPoolStrategy ignored={})
 Construct a non-threaded pool, ignoring using the hardware strategy.
 
 ~SingleThreadExecutor () override
 Blocking destructor: the pool will first execute the pending tasks.
 
void wait () override
 Blocking wait for all the tasks to execute first.
 
void wait (ThreadPoolTaskGroup &Group) override
 Blocking wait for only all the tasks in the given group to complete.
 
unsigned getMaxConcurrency () const override
 Returns always 1: there is no concurrency.
 
unsigned getThreadCount () const
 
bool isWorkerThread () const
 Returns true if the current thread is a worker thread of this thread pool.
 
- Public Member Functions inherited from llvm::ThreadPoolInterface
virtual ~ThreadPoolInterface ()
 Destroying the pool will drain the pending tasks and wait.
 
virtual void wait ()=0
 Blocking wait for all the threads to complete and the queue to be empty.
 
virtual void wait (ThreadPoolTaskGroup &Group)=0
 Blocking wait for only all the threads in the given group to complete.
 
virtual unsigned getMaxConcurrency () const =0
 Returns the maximum number of worker this pool can eventually grow to.
 
template<typename Function , typename... Args>
auto async (Function &&F, Args &&...ArgList)
 Asynchronous submission of a task to the pool.
 
template<typename Function , typename... Args>
auto async (ThreadPoolTaskGroup &Group, Function &&F, Args &&...ArgList)
 Overload, task will be in the given task group.
 
template<typename Func >
auto async (Func &&F) -> std::shared_future< decltype(F())>
 Asynchronous submission of a task to the pool.
 
template<typename Func >
auto async (ThreadPoolTaskGroup &Group, Func &&F) -> std::shared_future< decltype(F())>
 

Detailed Description

A non-threaded implementation.

Definition at line 218 of file ThreadPool.h.

Constructor & Destructor Documentation

◆ SingleThreadExecutor()

SingleThreadExecutor::SingleThreadExecutor ( ThreadPoolStrategy  ignored = {})

Construct a non-threaded pool, ignoring using the hardware strategy.

Definition at line 193 of file ThreadPool.cpp.

References llvm::ThreadPoolStrategy::compute_thread_count(), and llvm::errs().

◆ ~SingleThreadExecutor()

SingleThreadExecutor::~SingleThreadExecutor ( )
override

Blocking destructor: the pool will first execute the pending tasks.

Definition at line 220 of file ThreadPool.cpp.

References wait().

Member Function Documentation

◆ getMaxConcurrency()

unsigned llvm::SingleThreadExecutor::getMaxConcurrency ( ) const
inlineoverridevirtual

Returns always 1: there is no concurrency.

Implements llvm::ThreadPoolInterface.

Definition at line 233 of file ThreadPool.h.

◆ getThreadCount()

unsigned llvm::SingleThreadExecutor::getThreadCount ( ) const
inline

Definition at line 237 of file ThreadPool.h.

◆ isWorkerThread()

bool SingleThreadExecutor::isWorkerThread ( ) const

Returns true if the current thread is a worker thread of this thread pool.

Definition at line 216 of file ThreadPool.cpp.

References llvm::report_fatal_error().

◆ wait() [1/2]

void SingleThreadExecutor::wait ( )
overridevirtual

◆ wait() [2/2]

void SingleThreadExecutor::wait ( ThreadPoolTaskGroup Group)
overridevirtual

Blocking wait for only all the tasks in the given group to complete.

Implements llvm::ThreadPoolInterface.

Definition at line 210 of file ThreadPool.cpp.

References wait().


The documentation for this class was generated from the following files: