All Projects → DeveloperPaul123 → thread-pool

DeveloperPaul123 / thread-pool

Licence: MIT license
A modern thread pool implementation based on C++20

Programming Languages

C++
36643 projects - #6 most used programming language
CMake
9771 projects

Projects that are alternatives of or similar to thread-pool

thread-pool
BS::thread_pool: a fast, lightweight, and easy-to-use C++17 thread pool library
Stars: ✭ 1,043 (+902.88%)
Mutual labels:  concurrency, threading, thread-pool, threadpool
Threadly
A library of tools to assist with safe concurrent java development. Providing unique priority based thread pools, and ways to distrbute threaded work safely.
Stars: ✭ 196 (+88.46%)
Mutual labels:  high-performance, concurrency, threading, thread-pool
Agency
Execution primitives for C++
Stars: ✭ 127 (+22.12%)
Mutual labels:  concurrency, threading, thread-pool
Asyncio
asyncio historical repository
Stars: ✭ 952 (+815.38%)
Mutual labels:  high-performance, concurrency
not-enough-standards
A modern header-only C++ library that provides platform-independent utilities.
Stars: ✭ 197 (+89.42%)
Mutual labels:  thread-pool, cpp20
Stormpot
A fast object pool for the JVM
Stars: ✭ 267 (+156.73%)
Mutual labels:  high-performance, concurrency
Java Concurrency Examples
Java Concurrency/Multithreading Tutorial with Examples for Dummies
Stars: ✭ 173 (+66.35%)
Mutual labels:  concurrency, thread-pool
Vert.x
Vert.x is a tool-kit for building reactive applications on the JVM
Stars: ✭ 12,544 (+11961.54%)
Mutual labels:  high-performance, concurrency
Blog
Java Performance
Stars: ✭ 83 (-20.19%)
Mutual labels:  high-performance, thread-pool
Pond
Minimalistic and High-performance goroutine worker pool written in Go
Stars: ✭ 187 (+79.81%)
Mutual labels:  high-performance, concurrency
noroutine
Goroutine analogue for Node.js, spreads I/O-bound routine calls to utilize thread pool (worker_threads) using balancer with event loop utilization. 🌱
Stars: ✭ 86 (-17.31%)
Mutual labels:  concurrency, threads
MultiHttp
This is a high performance , very useful multi-curl tool written in php. 一个超级好用的并发CURL工具!!!(httpful,restful, concurrency)
Stars: ✭ 79 (-24.04%)
Mutual labels:  high-performance, concurrency
Corium
Corium is a modern scripting language which combines simple, safe and efficient programming.
Stars: ✭ 18 (-82.69%)
Mutual labels:  high-performance, concurrency
Object threadsafe
We make any object thread-safe and std::shared_mutex 10 times faster to achieve the speed of lock-free algorithms on >85% reads
Stars: ✭ 280 (+169.23%)
Mutual labels:  high-performance, concurrency
Pht
A new threading extension for PHP
Stars: ✭ 175 (+68.27%)
Mutual labels:  concurrency, threading
Akka
Build highly concurrent, distributed, and resilient message-driven applications on the JVM
Stars: ✭ 11,938 (+11378.85%)
Mutual labels:  high-performance, concurrency
YACLib
Yet Another Concurrency Library
Stars: ✭ 193 (+85.58%)
Mutual labels:  concurrency, thread-pool
GameThreadPool
游戏中常用的线程池,顺序队列和非顺序队列
Stars: ✭ 18 (-82.69%)
Mutual labels:  thread-pool, threadpool
Floyd
The Floyd programming language
Stars: ✭ 133 (+27.88%)
Mutual labels:  concurrency, threading
Simple-Log
dnkpp.github.io/Simple-Log/
Stars: ✭ 13 (-87.5%)
Mutual labels:  cpp20, cpp20-library

thread-pool

say thanks Discord

Ubuntu Windows Style Install

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.

License

The project is licensed under the MIT license. See LICENSE for more details.

Author


@DeveloperPaul123
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].