alpaka
Abstraction Library for Parallel Kernel Acceleration
alpaka::core::detail::ThreadPool Struct Referencefinal

A thread pool yielding when there is not enough work to be done. More...

#include <ThreadPool.hpp>

Public Types

using Task = std::packaged_task< void()>
 

Public Member Functions

 ThreadPool (std::size_t threadCount)
 Creates a thread pool with a given thread count. More...
 
 ~ThreadPool ()
 Destroys the thread pool, blocking until all enqueued work is done. More...
 
template<typename TFnObj , typename... TArgs>
auto enqueueTask (TFnObj &&task, TArgs &&... args) -> std::future< void >
 Runs the given function on one of the pool in First In First Out (FIFO) order. More...
 

Detailed Description

A thread pool yielding when there is not enough work to be done.

Definition at line 19 of file ThreadPool.hpp.

Member Typedef Documentation

◆ Task

using alpaka::core::detail::ThreadPool::Task = std::packaged_task<void()>

Definition at line 21 of file ThreadPool.hpp.

Constructor & Destructor Documentation

◆ ThreadPool()

alpaka::core::detail::ThreadPool::ThreadPool ( std::size_t  threadCount)
inlineexplicit

Creates a thread pool with a given thread count.

Definition at line 24 of file ThreadPool.hpp.

◆ ~ThreadPool()

alpaka::core::detail::ThreadPool::~ThreadPool ( )
inline

Destroys the thread pool, blocking until all enqueued work is done.

Definition at line 34 of file ThreadPool.hpp.

Member Function Documentation

◆ enqueueTask()

template<typename TFnObj , typename... TArgs>
auto alpaka::core::detail::ThreadPool::enqueueTask ( TFnObj &&  task,
TArgs &&...  args 
) -> std::future<void>
inline

Runs the given function on one of the pool in First In First Out (FIFO) order.

Parameters
taskFunction object to be called on the pool. Takes an arbitrary number of arguments. Must return void.
argsArguments for task, cannot be moved. If such parameters must be used, use a lambda and capture via move then move the lambda.
Returns
A future to the created task.

Definition at line 56 of file ThreadPool.hpp.


The documentation for this struct was generated from the following file: