alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
alpaka::core::CallbackThread Class Reference

A thread queue executing tasks asynchronously. More...

#include <CallbackThread.hpp>

Classes

struct  FunctionHolder
struct  State
struct  Task

Public Member Functions

 CallbackThread ()
 CallbackThread (uint32_t cpuGroupIdx)
 ~CallbackThread ()
bool isEmpty () const
template<typename NullaryFunction>
auto submit (NullaryFunction &&nf) -> std::future< void >
 It is guaranteed that the task is fully destroyed before the future's result is set.

Private Types

using TaskPackage = std::pair<std::unique_ptr<Task>, std::promise<void>>

Private Member Functions

auto startWorkerThread () -> void

Private Attributes

uint32_t m_cpuGroupIdx = onHost::internal::hwloc::allDomains
std::shared_ptr< Statem_state
 Hold data shared between this call and the thread processing the tasts.
std::jthread m_thread

Detailed Description

A thread queue executing tasks asynchronously.

This object should be used as a member of objects which are secured by smart pointers to avoid that a task is taking over the ownership of the callback thread and therefore can destroy itself before all tasks are executed.

Definition at line 26 of file CallbackThread.hpp.

Member Typedef Documentation

◆ TaskPackage

using alpaka::core::CallbackThread::TaskPackage = std::pair<std::unique_ptr<Task>, std::promise<void>>
private

Definition at line 61 of file CallbackThread.hpp.

Constructor & Destructor Documentation

◆ CallbackThread() [1/2]

alpaka::core::CallbackThread::CallbackThread ( uint32_t cpuGroupIdx)
inline

Definition at line 71 of file CallbackThread.hpp.

◆ CallbackThread() [2/2]

alpaka::core::CallbackThread::CallbackThread ( )
inline

Definition at line 75 of file CallbackThread.hpp.

◆ ~CallbackThread()

alpaka::core::CallbackThread::~CallbackThread ( )
inline

Definition at line 79 of file CallbackThread.hpp.

Member Function Documentation

◆ isEmpty()

bool alpaka::core::CallbackThread::isEmpty ( ) const
inline

Definition at line 129 of file CallbackThread.hpp.

◆ startWorkerThread()

auto alpaka::core::CallbackThread::startWorkerThread ( ) -> void
inlineprivate

Definition at line 141 of file CallbackThread.hpp.

◆ submit()

template<typename NullaryFunction>
auto alpaka::core::CallbackThread::submit ( NullaryFunction && nf) -> std::future< void >
inline

It is guaranteed that the task is fully destroyed before the future's result is set.

Definition at line 105 of file CallbackThread.hpp.

Member Data Documentation

◆ m_cpuGroupIdx

uint32_t alpaka::core::CallbackThread::m_cpuGroupIdx = onHost::internal::hwloc::allDomains
private

Definition at line 139 of file CallbackThread.hpp.

◆ m_state

std::shared_ptr<State> alpaka::core::CallbackThread::m_state
private

Hold data shared between this call and the thread processing the tasts.

Definition at line 138 of file CallbackThread.hpp.

◆ m_thread

std::jthread alpaka::core::CallbackThread::m_thread
private

Definition at line 136 of file CallbackThread.hpp.


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