tdauth / cpp-futures-promises

Advanced futures and promises in C++.
GNU General Public License v3.0
16 stars 0 forks source link

Advanced Futures and Promises in C++

This project provides an advanced futures and promises library based on our papers Advanced Futures and Promises in C++ and Futures and Promises in Haskell and Scala. The library offers functions which are missing from other C++ futures and promises libraries. It is implemented with the help of only a few core operations which allows a much easier adaption to different implementations. Advanced futures and promises are shared by default. Currently, the library has one reference implementation which uses MVars.

The derived features were inspired by Scala library for futures and promises and Folly.

You can watch this German presentation about this project. The slides can be found here.

Automatic Build with TravisCI

Build Status Code Coverage

Manual Build

To compile the project run one of the the following Bash scripts on Linux:

They will compile the project. The first two will run all unit tests. The third will create an RPM package. Note that all targets are added as CTest unit tests which simplifies their execution. The dependencies will be downloaded and compiled automatically. Therefore, you need Internet access when building for the first time.

Dependencies

The project requires the GCC with C++17 support and CMake to be built.

The project requires the following libraries:

It will download and compile Folly automatically when being compiled. The version of Folly is specified in the CMakeLists.txt file.

State of the Art

Existing C++ libraries for futures and promises:

Disadvantages of Folly:

Advanced Futures and Promises

This library addresses the disadvantages of Folly. It adds missing non-blocking combinators, futures support multiple callbacks, futures and promises can be copied and futures allow multiple read semantics.

Abstraction of the Core Operations

The class template adv::Core<T> has to be implemented to provide a custom implementation.

Performance Tests

Recursive non-blocking combinator calls: Compares the performance of the different non-blocking combinators. It creates a binary tree with a fixed height per test case. Every node in the tree is the call of a non-blocking combinator.

Presentation at C++ User Group Karlsruhe

The folder cpp_user_group_karlsruhe contains examples from the presentation for the C++ User Group Karlsruhe.

C++ Paper

We have written a paper about the advanced futures and promises called Advanced Futures and Promises in C++. Here are some TODOs for the paper:

Boost.Thread Implementation

Folly Changes

Performance Analysis

Better Abstraction

These changes bring a lot of performance issues with them. You should look into Rust futures which use traits -> more like template meta programming. Maybe this approach would be better to avoid virtual methods and heap allocation.

New Features

Maybe add the new derived methods to adv::Future: