Skip to content

Class star::ThreadPool

ClassList > star > ThreadPool

Simple thread pool for parallel block operations. More...

  • #include <stards.h>

Public Functions

Type Name
ThreadPool (size_t num_threads=0)
Construct thread pool.
ThreadPool (const ThreadPool &) = delete
ThreadPool (ThreadPool &&) = delete
std::future< void > enqueue (Func && f)
Enqueue a task for execution.
ThreadPool & operator= (const ThreadPool &) = delete
ThreadPool & operator= (ThreadPool &&) = delete
void parallel_for (size_t start, size_t end, Func && func)
Execute function in parallel for range [start, end).
size_t size () const
Get number of worker threads.
~ThreadPool ()
Destructor - stops all worker threads.

Detailed Description

Provides work-stealing task execution for parallel compression/decompression. Thread-safe and exception-safe.

Public Functions Documentation

function ThreadPool [1/3]

Construct thread pool.

inline explicit star::ThreadPool::ThreadPool (
    size_t num_threads=0
) 

Parameters:

  • num_threads Number of worker threads (0 = auto-detect)

function ThreadPool [2/3]

star::ThreadPool::ThreadPool (
    const ThreadPool &
) = delete

function ThreadPool [3/3]

star::ThreadPool::ThreadPool (
    ThreadPool &&
) = delete

function enqueue

Enqueue a task for execution.

template<typename Func>
inline std::future< void > star::ThreadPool::enqueue (
    Func && f
) 

Parameters:

  • f Function to execute

Returns:

Future for result


function operator=

ThreadPool & star::ThreadPool::operator= (
    const ThreadPool &
) = delete

function operator=

ThreadPool & star::ThreadPool::operator= (
    ThreadPool &&
) = delete

function parallel_for

Execute function in parallel for range [start, end).

template<typename Func>
inline void star::ThreadPool::parallel_for (
    size_t start,
    size_t end,
    Func && func
) 

Parameters:

  • start Start index (inclusive)
  • end End index (exclusive)
  • func Function to execute for each index

function size

Get number of worker threads.

inline size_t star::ThreadPool::size () const


function ~ThreadPool

Destructor - stops all worker threads.

inline star::ThreadPool::~ThreadPool () 



The documentation for this class was generated from the following file StarDS/include/stards.h