https://github.com/tzcnt/toomanycooks
C++20 thread pool / tasking library / coroutine runtime with no compromises. Excellent performance, powerful features, and simple syntax.
https://github.com/tzcnt/toomanycooks
concurrency coroutines cpp cpp20 lock-free multi-threading multithreading parallel task-graph tasking threadpool wait-free work-stealing
Last synced: 29 days ago
JSON representation
C++20 thread pool / tasking library / coroutine runtime with no compromises. Excellent performance, powerful features, and simple syntax.
- Host: GitHub
- URL: https://github.com/tzcnt/toomanycooks
- Owner: tzcnt
- License: bsl-1.0
- Created: 2023-09-02T02:05:24.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-05-06T00:10:33.000Z (about 1 month ago)
- Last Synced: 2025-05-07T09:15:10.288Z (29 days ago)
- Topics: concurrency, coroutines, cpp, cpp20, lock-free, multi-threading, multithreading, parallel, task-graph, tasking, threadpool, wait-free, work-stealing
- Language: C++
- Homepage:
- Size: 437 KB
- Stars: 31
- Watchers: 3
- Forks: 0
- Open Issues: 18
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
   
   [](https://codecov.io/gh/tzcnt/TooManyCooks)
## TooManyCooks
TooManyCooks is a runtime and concurrency library for C++20 coroutines. Its goals:
- be the fastest general-purpose coroutine library available ([see the benchmarks](https://github.com/tzcnt/runtime-benchmarks))
- absolutely no-fuss API
- extensive feature set
- simple and clear path to migrate legacy applications
- simple and clear path to integrate with 3rd-party executors/event loopsIt provides:
- a blazing fast lock-free work-stealing thread pool (`ex_cpu`) that supports both coroutines and regular functors
- automatic, hardware-optimized thread configuration via [hwloc](https://www.open-mpi.org/projects/hwloc/)
- network I/O, file I/O, and timers support by integration with Asio (via [tmc-asio](https://github.com/tzcnt/tmc-asio))
- a global executor instance so you can submit work from anywhere
- support for multiple task priority levels
- a suite of utility functions for fluently interacting with tasks, awaitables, and executors
- traits-based extensibility for 3rd party awaitables and executors### Read the [Documentation](https://fleetcode.com/oss/tmc/docs), try out the [Examples](https://github.com/tzcnt/tmc-examples), and run the [Tests](https://github.com/tzcnt/tmc-examples/tree/main/tests).
### Building
TooManyCooks is a header-only library. You can either include the specific headers that you need in each file, or `#include "tmc/all_headers.hpp"`, which contains all of the other headers.In exactly one file, you must `#define TMC_IMPL` before including the headers. This will generate the function definitions for the library into that file. The simplest way to accomplish this is to put it in your `main.cpp`. Creating a [standalone compilation file](https://github.com/tzcnt/tmc-examples/blob/main/tests/standalone_compilation.cpp) is also trivial.
### Quick Start
```cpp
#define TMC_IMPL
#include "tmc/all_headers.hpp"
int main() {
return tmc::async_main(()[] -> tmc::task {
// Hello, async world!
co_return 0;
}());
}
```### Configuration
TooManyCooks will work out of the box as a header-only library without any configuration.
However, some performance tuning options are available. See the documentation section [Build-Time Options](https://fleetcode.com/oss/tmc/docs/v0.1.0/build_flags.html) for more info.### Roadmap
See the [issues tagged "enhancement"](https://github.com/tzcnt/TooManyCooks/issues?q=is%3Aissue%20state%3Aopen%20label%3Aenhancement) for future planned work. Please leave a :thumbsup: on any issues that are important to you. I will use this as a way to gauge community interest on what should be developed next.### Supported Compilers
Linux:
- Clang 17 or newer
- GCC 14 or newerWindows:
- Clang 17 or newer (via clang-cl.exe)
- ~~MSVC 19.42.34436~~MSVC has an open bug with symmetric transfer and final awaiters that destroy the coroutine frame. The code will compile, but crashes at runtime. ([bug link](https://developercommunity.visualstudio.com/t/Incorrect-code-generation-for-symmetric/1659260?scope=follow&viewtype=all))
### Supported Hardware
- x86 (32- or 64-bit)
- AArch64TooManyCooks has been tested on the following physical devices:
- Intel i7 4770k
- AMD Ryzen 5950X
- AMD EPYC 7742
- Rockchip RK3588S (in a Khadas Edge2)