Coder Social home page Coder Social logo

asyncplusplus's Introduction

Async++

Async++ is a lightweight concurrency framework for C++11. The concept was inspired by the Microsoft PPL library and the N3428 C++ standard proposal.

Example

Here is a short example which shows some features of Async++:

#include <iostream>
#include <async++.h>

int main()
{
    auto task1 = async::spawn([] {
        std::cout << "Task 1 executes asynchronously" << std::endl;
    });
    auto task2 = async::spawn([]() -> int {
        std::cout << "Task 2 executes in parallel with task 1" << std::endl;
        return 42;
    });
    auto task3 = task2.then([](int value) -> int {
        std::cout << "Task 3 executes after task 2, which returned " << value << std::endl;
        return value * 3;
    });
    auto task4 = async::when_all(task1, task3).then([](std::tuple<async::void_, int> results) {
        std::cout << "Task 4 executes after tasks 1 and 3. Task 3 returned " << std::get<1>(results) << std::endl;
    });

    task4.get();
    std::cout << "Task 4 has completed" << std::endl;
}

// Output (order of tasks 1 and 2 may be different):
// Task 1 executes asynchronously
// Task 2 executes in parallel with task 1
// Task 3 executes after task 2, which returned 42
// Task 4 executes after tasks 1 and 3. Task 3 returned 126
// Task 4 has completed

Supported Platforms

The only requirement to use Async++ is a C++11 compiler and standard library. Unfortunately C++11 is not yet fully implemented on most platforms. Here is the list of OS and compiler combinations which are known to work.

  • Linux: GCC 4.7+ and Clang 3.2+ work.
  • Mac: Works with Apple Clang (using libc++). GCC also works but you must get a recent version (4.7+).
  • Windows: GCC 4.8+ with posix threads works. MSVC and Intel compilers are not supported.

Building and Installing

Instructions for compiling Async++ and using it in your code are available on the Building and Installing page.

Tutorial

The Tutorial provides a step-by-step guide to all the features of Async++.

API Reference

The API Reference gives detailed descriptions of all the classes and functions available in Async++.

Contact

You can contact me by email at [email protected].

asyncplusplus's People

Contributors

amanieu avatar fpelliccioni avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.