thread-pool alternatives and similar libraries
Based on the "Concurrency" category.
Alternatively, view thread-pool alternatives based on common mentions on social networks and blogs.
-
moodycamel
A fast multi-producer, multi-consumer lock-free concurrent queue for C++11 -
Taskflow
A General-purpose Parallel and Heterogeneous Task Programming System -
readerwriterqueue
A fast single-producer, single-consumer lock-free queue for C++ -
C++ Actor Framework
An Open Source Implementation of the Actor Model in C++ -
ck
Concurrency primitives, safe memory reclamation mechanisms and non-blocking (including lock-free) data structures designed to aid in the research, design and implementation of high performance concurrent systems developed in C99+. -
MPMCQueue.h
A bounded multi-producer multi-consumer concurrent queue written in C++11 -
RaftLib
The RaftLib C++ library, streaming/dataflow concurrency via C++ iostream-like operators -
VexCL
VexCL is a C++ vector expression template library for OpenCL/CUDA/OpenMP -
continuable
C++14 asynchronous allocation aware futures (supporting then, exception handling, coroutines and connections) -
SPSCQueue.h
A bounded single-producer single-consumer wait-free and lock-free queue written in C++11 -
A C++14 library for executors
C++ library for executors -
Bolt
Bolt is a C++ template library optimized for GPUs. Bolt provides high-performance library implementations for common algorithms such as scan, reduce, transform, and sort. -
xenium
A C++ library providing various concurrent data structures and reclamation schemes. -
CUB
THIS REPOSITORY HAS MOVED TO github.com/nvidia/cub, WHICH IS AUTOMATICALLY MIRRORED HERE. -
SObjectizer
SObjectizer: it's all about in-process message dispatching! -
Light Actor Framework
Laughably simple yet effective Actor concurrency framework for C++20 -
BlockingCollection
C++11 thread safe, multi-producer, multi-consumer blocking queue, stack & priority queue class -
Libclsph
OpenCL based GPU accelerated SPH fluid simulation library -
Easy Creation of GnuPlot Scripts from C++
A simple C++17 lib that helps you to quickly plot your data with GnuPlot -
alpaka
The project alpaka has moved to https://github.com/alpaka-group/alpaka -
eXtended Template Library
eXtended Template Library -
cupla
The project alpaka has moved to https://github.com/alpaka-group/cupla
ONLYOFFICE Docs — document collaboration in your environment
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of thread-pool or a related project?
README
thread-pool
A simple, functional thread pool implementation using pure C++20.
Features
- Built entirely with C++20
- Enqueue tasks with or without tracking results
Integration
dp::thread-pool
is a header only library. All the files needed are in include/thread_pool
.
CMake
ThreadPool
defines two CMake targets:
ThreadPool::ThreadPool
dp::thread-pool
You can then use find_package()
:
find_package(dp::thread-pool REQUIRED)
Alternatively, you can use something like CPM which is based on CMake's Fetch_Content
module.
CPMAddPackage(
NAME thread-pool
GITHUB_REPOSITORY DeveloperPaul123/thread-pool
GIT_TAG #0cea9c12fb30cb677696c0dce6228594ce26171a change this to latest commit or release tag
)
Usage
Simple example:
// create a thread pool with a specified number of threads.
dp::thread_pool pool(4);
// add tasks, in this case without caring about results of individual tasks
pool.enqueue_detach([](int value) { /*...your task...*/ }, 34);
pool.enqueue_detach([](int value) { /*...your task...*/ }, 37);
pool.enqueue_detach([](int value) { /*...your task...*/ }, 38);
// and so on..
You can see other examples in the /examples
folder.
Benchmarks
See the ./benchmark
folder for the benchmark code. The benchmarks are set up to compare matrix multiplication using the dp::thread_pool
versus std::async
. A summary of the comparisons is below. Benchmarks were run using the windows-release
CMake preset (see CMakePresets.json
).
Machine Specs
- AMD Ryzen 7 1800X (16 X 3593 MHz CPUs)
- CPU Caches:
- L1 Data 32 KiB (x8)
- L1 Instruction 64 KiB (x8)
- L2 Unified 512 KiB (x8)
- L3 Unified 8192 KiB (x2)
- 32 GB RAM
Summary of Results
Matrix sizes are all square (MxM). Each multiplication is (MxM) * (MxM)
where *
refers to a matrix multiplication operation. Times recorded were the best of at least 3 runs.
Matrix Size | Number of multiplications | std::async time (ms) |
dp::thread_pool time (ms) |
---|---|---|---|
8 | 25,000 | 77.9 | 65.3 |
64 | 5,000 | 100 | 65.2 |
256 | 250 | 295 | 59.2 |
512 | 75 | 713 | 60.4 |
1024 | 10 | 1160 | 55.8 |
Building
This project has been built with:
- Visual Studio 2022
- Clang
10.+
(via WSL on Windows) - GCC
11.+
(vis WSL on Windows) - CMake
3.21+
To build, run:
cmake -S . -B build
cmake --build build
Build Options
Option | Description | Default |
---|---|---|
TP_BUILD_TESTS |
Turn on to build unit tests. Required for formatting build targets. | ON |
TP_BUILD_EXAMPLES |
Turn on to build examples | ON |
Run clang-format
Use the following commands from the project's root directory to check and fix C++ and CMake source style.
This requires clang-format, cmake-format and pyyaml to be installed on the current system. To use this feature you must turn on TP_BUILD_TESTS
.
# view changes
cmake --build build/test --target format
# apply changes
cmake --build build/test --target fix-format
See Format.cmake for details.
Build the documentation
The documentation is automatically built and published whenever a GitHub Release is created. To manually build documentation, call the following command.
cmake -S documentation -B build/doc
cmake --build build/doc --target GenerateDocs
# view the docs
open build/doc/doxygen/html/index.html
To build the documentation locally, you will need Doxygen and Graphviz on your system.
Contributing
Contributions are very welcome. Please see [contribution guidelines for more info](CONTRIBUTING.md).
License
The project is licensed under the MIT license. See [LICENSE](LICENSE) for more details.
Author
@DeveloperPaul123 |
---|
*Note that all licence references and agreements mentioned in the thread-pool README section above
are relevant to that project's source code only.