A blazing-fast, lightweight, work-stealing thread-pool for C++20. Built on the lock-free concurrent riften::Deque
.
#include "riften/thiefpool.hpp" // Create thread pool with 4 worker threads. riften::Thiefpool pool(4); // Enqueue and return future. auto result = pool.enqueue([](int x) { return x; }, 42); // Get result from future. std::cout << result.get() << std::endl;
Additionally, riften::Thiefpool
supplies a detaching version of enqueue:
// Enqueue and return nothing pool.enqueue_detach([](int x) { do_work(x); }, x);
Which elides the allocation of a std::future
's shared state.
The recommended way to consume this library is through CPM.cmake, just add:
CPMAddPackage("gh:ConorWilliams/Threadpool#v2.1.1")
to your CMakeLists.txt
and you're good to go!
To compile and run the tests:
mkdir build && cd build cmake ../test make && make test
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4