CNum 0.2.1
CPU-optimized ML library for C++
Loading...
Searching...
No Matches
CNum::Multithreading::ThreadPool Class Reference

A promise based thread pool. More...

#include <ThreadPool.h>

Public Member Functions

 ~ThreadPool ()
 Destructor.
 ThreadPool (const ThreadPool &other)=delete
ThreadPool & operator= (const ThreadPool &other)=delete
 ThreadPool (ThreadPool &&other)=delete
ThreadPool & operator= (ThreadPool &&other)=delete
void shutdown ()
 Shut the ThreadPool down.
template<typename T>
std::future< T > submit (std::function< T(arena_t *arena) > f)
 Submit a task to the ThreadPool.

Static Public Member Functions

static ThreadPool * get_thread_pool (ThreadPoolConfig config={ default_arena_init_block_ct })
 Get the instance of the ThreadPool singleton.
static int get_worker_id ()
 Get the thread-local id of a worker.

Detailed Description

A promise based thread pool.

Constructor & Destructor Documentation

◆ ~ThreadPool()

CNum::Multithreading::ThreadPool::~ThreadPool ( )

Destructor.

◆ ThreadPool() [1/2]

CNum::Multithreading::ThreadPool::ThreadPool ( const ThreadPool & other)
delete

◆ ThreadPool() [2/2]

CNum::Multithreading::ThreadPool::ThreadPool ( ThreadPool && other)
delete

Member Function Documentation

◆ get_thread_pool()

ThreadPool * CNum::Multithreading::ThreadPool::get_thread_pool ( ThreadPoolConfig config = default_arena_init_block_ct })
static

Get the instance of the ThreadPool singleton.

Parameters
configThe configuration of the ThreadPool
Returns
A raw pointer to the instance of the ThreadPool

◆ get_worker_id()

int CNum::Multithreading::ThreadPool::get_worker_id ( )
static

Get the thread-local id of a worker.

Returns
The worker id

◆ operator=() [1/2]

ThreadPool & CNum::Multithreading::ThreadPool::operator= ( const ThreadPool & other)
delete

◆ operator=() [2/2]

ThreadPool & CNum::Multithreading::ThreadPool::operator= ( ThreadPool && other)
delete

◆ shutdown()

void CNum::Multithreading::ThreadPool::shutdown ( )

Shut the ThreadPool down.

◆ submit()

template<typename T>
std::future< T > CNum::Multithreading::ThreadPool::submit ( std::function< T(arena_t *arena) > f)
inline

Submit a task to the ThreadPool.

Parameters
fThe task
Returns
A future that will contain whatever the task returns

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