Skip to content

C++20 thread pool / tasking library / coroutine runtime with no compromises. Excellent performance, powerful features, and simple syntax.

License

Notifications You must be signed in to change notification settings

tzcnt/TooManyCooks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

x64-linux-gcc x64-linux-clang x64-windows-clang-cl arm64-macos-clang

AddressSanitizer ThreadSanitizer UndefinedBehaviorSanitizer codecov

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)
  • 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 loops

It 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
  • network I/O, file I/O, and timers support by integration with Asio (via 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, try out the Examples, and run the 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 is also trivial.

Quick Start

#define TMC_IMPL
#include "tmc/all_headers.hpp"
int main() {
  return tmc::async_main(()[] -> tmc::task<int> {
    // 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 for more info.

Roadmap

See the issues tagged "enhancement" for future planned work. Please leave a 👍 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 newer

Windows:

  • 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)

Supported Hardware

  • x86 (32- or 64-bit)
  • AArch64

TooManyCooks has been tested on the following physical devices:

  • Intel i7 4770k
  • AMD Ryzen 5950X
  • AMD EPYC 7742
  • Rockchip RK3588S (in a Khadas Edge2)

About

C++20 thread pool / tasking library / coroutine runtime with no compromises. Excellent performance, powerful features, and simple syntax.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages