A C++ header-only library, that implements a thread pool.

A thread pool maintains multiple threads, that are waiting for work to be allocated for concurrent execution. This
increases performance and avoids latency in execution due to frequent creation and destruction of threads.

Getting started

To use Arcc, simply clone the repository, copy-paste the arcc.h header file to your project and include it in your

#include "arcc.h"

The thread pool will now be available via the arcc::thread_pool class. The library should successfully compile on any
C++11 standard-compliant compiler. For better performance, the program should be compiled with -O2 or /O2 (MSVC)
flags accordingly.

An example program can be found in the example.cpp file and can be compiled with CMake.

Tasks and jobs

This library uses tasks and jobs to represent units of work, that will be added to the thread pool. Tasks are
lightweight compared to jobs, but have some limitations.

Usually, it is best to add work to the thread pool via the add_job() function. This allows you to wait for the job to
finish and get its return value later, as the mentioned function always returns a std::future. But sometimes, a future
isn’t needed. That’s where tasks and jobs differ.

A task can be viewed as a “fire and forget” job. When a function communicates with the main thread via pointers and
references, or if you don’t care, when the function will complete, use a task. Tasks can be added to the pool via the
add_task() function.

Note: Thread pool’s destructor will always wait for all tasks and jobs to complete.


View Github