Skip to content

ConorWilliams/Threadpool

Repository files navigation

riften::Thiefpool

A blazing-fast, lightweight, work-stealing thread-pool for C++20. Built on the lock-free concurrent riften::Deque.

Usage

#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.

Installation

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!

Tests

To compile and run the tests:

mkdir build && cd build
cmake ../test
make && make test

About

Light, fast, threadpool for C++20

Topics

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •  
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy