Async++ concurrency framework for C++11

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);
    auto task5 = task4.then([](std::tuple<async::task<void>,
                                          async::task<int>> results) {
        std::cout << "Task 5 executes after tasks 1 and 3. Task 3 returned "
                  << std::get<1>(results).get() << std::endl;
    });

    task5.get();
    std::cout << "Task 5 has completed" << std::endl;

    async::parallel_invoke([] {
        std::cout << "This is executed in parallel..." << std::endl;
    }, [] {
        std::cout << "with this" << std::endl;
    });

    async::parallel_for(async::irange(0, 5), [](int x) {
        std::cout << x;
    });
    std::cout << std::endl;

    int r = async::parallel_reduce({1, 2, 3, 4}, 0, [](int x, int y) {
        return x + y;
    });
    std::cout << "The sum of {1, 2, 3, 4} is " << r << std::endl;
}

// Output (order may vary in some places):
// Task 1 executes asynchronously
// Task 2 executes in parallel with task 1
// Task 3 executes after task 2, which returned 42
// Task 5 executes after tasks 1 and 3. Task 3 returned 126
// Task 5 has completed
// This is executed in parallel...
// with this
// 01234
// The sum of {1, 2, 3, 4} is 10

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: Works with GCC 4.7+, Clang 3.2+ and Intel compiler 15+.
  • Mac: Works with Apple Clang (using libc++). GCC also works but you must get a recent version (4.7+).
  • iOS: Works with Apple Clang (using libc++). Note: because iOS has no thread local support, the library uses a workaround based on pthreads.
  • Windows: Works with GCC 4.8+ (with pthread-win32) and Visual Studio 2013+.

Building and Installing

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

Documentation

The Async++ documentation is split into four parts:

  • Tasks: This describes task objects which are the core Async++. Reading this first is strongly recommended.
  • Parallel algorithms: This describes functions to run work on ranges in parallel.
  • Schedulers: This describes the low-level details of Async++ and how to customize it.
  • API Reference: This gives detailed descriptions of all the classes and functions available in Async++.

Contact

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

Comments
  • Nested task spawning broken

    Nested task spawning broken

    When I use nested tasks with async::spawn() and async::get(), the synchronization doesn't work properly. This happens pretty consistently, and I am forced to never spawn tasks from tasks, which can be very limiting.

    In the example below, some of the get()s will return before the work has completed, causing bugs.

    Aside from this, the library is very convenient and works well.

    Thanks! Rob

    void Function1()
    {
    	async::task<void> tasks[100];
    	for (int t=0; t<100; t++)
    	{
    		tasks[t] = async::spawn([=]
    		{
    			Function2();
    		});
    	}
    
    	for (int t=0; t<100; t++)
    		tasks[t].get();
    }
    
    void Function2()
    {
    	async::task<void> tasks[100];
    	for (int t=0; t<100; t++)
    	{
    		tasks[t] = async::spawn([=]
    		{
    			DoWork();
    		});
    	}
    
    	for (int t=0; t<100; t++)
    		tasks[t].get();
    }
    
    
  • Is it safe to export thread_id as a global thread local variable?

    Is it safe to export thread_id as a global thread local variable?

    Hi, I'm using parallel_for extensively and some of my lambdas rely on thread identifiers. I wonder if directly exposing thread_id is a good idea. Thanks!

  • .error(...) continuation support

    .error(...) continuation support

    User can specify a .error(…) function that gets called only if .cancel() is called on a parent task. This is useful to implement a Promise like functionality using event_task, so that it can be “fullfilled” by calling set or “rejected” by calling .cancel()

    Example:

    
    #define LIBASYNC_DEFAULT_SCHEDULER async::inline_scheduler()
    #include <async++.h>
    
    template<typename T>
    using Promise = async::event_task<T>;
    
    int main(int argc, const char * argv[])
    {
        using namespace async;
    
        // Create an event
        Promise<int> e;
    
        // Get a task associated with the event
        auto t = e.get_task();
    
        decltype(e) e1;
        // Add a continuation to the task
        t
        .then([&](int result)
        {
            printf("then1=%d\n",result);
            return result + 1;
        })
        .then([](int result)
        {
            printf("then2=%d\n",result);
            return result + 1.5;
        })
        .then([](float result)
        {
            printf("then3=%f\n",result);
            return result;
        })
        .error([](int res)
        {
            //executed only if e.cancel() is called
            printf("Task 1 ERROR occurred\n");
            return res;
        }).then([&](int res)
        {
            printf("THIS IS ALWAYS executed\n");
            return e1.get_task();
        }).then([&](int res)
        {
            printf("Task 2 executed\n");
            return res;
        }).error([](int res)
        {
            //executed only if e1.cancel() is called
            printf("Task 2 ERROR occurred\n");
        });
    
        // Set the event value, which will cause the continuation to run
        e.set(42);
        e1.set(44);
        //e.cancel();
        //e1.cancel();
        printf("End of program\n");
    
        return 0;
    }
    
  • wait on parallel_for results

    wait on parallel_for results

    Is it possible to wait on parallel_for results to then synchronously use all the results together? Or how is this issue solvable with your API? I was hoping parallel_for would return tasks that I could .when_all() on, but it's void.

  • Implement a thread_local emulation for iOS devices

    Implement a thread_local emulation for iOS devices

    Apparently Apple does not implement any compiler based thread local storage on iOS. But pthread is capable of storing thread local data.

    This pull requests adds a macro called EMULATE_PTHREAD_THREAD_LOCAL that enables the emulation.

    I have also changed the way the thread-global variables are accessed because pthread cannot map transparently to a variable (it could be done with templates... but i tried to keep it simple): a function is used to setup, get and set a thread local instead of a variable directly.

  • event_task and continuation

    event_task and continuation

    Hi, and thank you for this great project!

    The output of the sample program below:

    int main()
    {
        std::cout << "main thread:" << std::this_thread::get_id() << std::endl;
    
        async::event_task<int> event;
    
        async::spawn(async::inline_scheduler(),[&event]() {
            std::cout << "event_task: " << std::this_thread::get_id() << std::endl;
            return event.get_task();
        }).then(async::inline_scheduler(),[](int) {
            std::cout << "continuation: " << std::this_thread::get_id() << std::endl;
        });
        event.set(5);
        return 0;
    }
    

    is something like: main thread:139639703947136 event_task: 139639703947136 continuation: 139639666984704

    Shouldn't everything run on the same thread?

  • async::when_any crashes

    async::when_any crashes

    The following code crashes often with Clang 8.0 on MacOSX , what am I doing wrong ?

    #include <iostream>
    #include <array>
    #include <async++.h>
    
    int main ()
    {
      std::array<async::task<char>,3> tasks {
        async::spawn([] {return 'A';}),
        async::spawn([] {return 'B';}),
        async::spawn([] {return 'C';}),
      };
    
      async::when_any(tasks.begin(),tasks.end()).then(
      [](async::when_any_result<std::vector<async::task<char>>> result) {
        std::cout << "Task " << result.index << " finished with value "
                  << result.tasks[result.index].get() << std::endl;
      });
      return 0;
    }
    
  • Update / simplify + cmake

    Update / simplify + cmake

    I really like what you have done here. Do you plan on updating it since many compilers now support C++11? There are also other enhancements that might be nice to add such as Travis-CI, cmake, and unit testing.

    I forked the project and I was able to get it to compile on Mac OS X using cmake but when I ran it on Travis it bombed. I looked at the code and there was a lot I didn't understand. I can however refork if you like and merge in / show you my changes.

    Mostly I'm just curious to find out what you are planning for the project if anything.

  • async block never invoked

    async block never invoked

    I have some async block like

            async::spawn([this, &resource](){
                ... // resource loading here
            });
    

    I call method that loads resources then it finishes its job. I call it one more time and all async blocks is never invoked anymore...

  • error on centos 7

    error on centos 7

    I tried to compile my project using async++ for the first time on Centos7 using gcc 4.8.2 and I got this error:

    undefined reference to `void std::atomic_init<async::detail::compressed_ptr<3ul, true> >(std::atomic<async::detail::compressed_ptr<3ul, true> >*, async::detail::compressed_ptr<3ul, true>)'
    

    Does it mean something to you? Thanks for your help

  • Compilation failures in C++20 due to removal of std::result_of

    Compilation failures in C++20 due to removal of std::result_of

    I'm using asyncplusplus from a C++20 project and it's failing to compile because std::result_of was removed in C++20. I worked around this problem by replacing std::result_of with std::invoke_result in my fork. You can see the changes here: https://github.com/IanLilleyT/asyncplusplus/commit/1a9cbc504eb675e42524c44f9ecf46973574b257. I opened an issue instead of a PR because I'm not sure if this library wants to include C++17 code in its headers, even if it's behind a macro. Let me know if I should turn this into a PR or not.

    The cmake code / comment is partly taken from: https://stackoverflow.com/a/60890947

    Thanks for reading!

  • Add explicit move constructor / move assignment for shared_task

    Add explicit move constructor / move assignment for shared_task

    When upgrading to using gcc-11 with C++ 20, it is no longer possible to assign a task to a shared_task as in:

    async::shared_task<cb_result> task{async::make_task(cb_result::CB_S_OK)};
    

    Therefore an explicit move-constructor and move-assignment operator have been added to shared_task:

    	shared_task(task<Result>&& other)
    	shared_task& operator=(task<Result>&& other)
    
  • ERROR: terminate called without an active exception on QT application

    ERROR: terminate called without an active exception on QT application

    main.cpp

    #include "mainwindow.h"
    #include <iostream>
    #include <QApplication>
    #include "async++.h"
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
    
        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);
        auto task5 = task4.then([](std::tuple<async::task<void>,
                                              async::task<int>> results) {
            std::cout << "Task 5 executes after tasks 1 and 3. Task 3 returned "
                      << std::get<1>(results).get() << std::endl;
        });
    
        task5.get();
        std::cout << "Task 5 has completed" << std::endl;
    
    
        async::parallel_invoke([] {
            std::cout << "This is executed in parallel..." << std::endl;
        }, [] {
            std::cout << "with this" << std::endl;
        });
    
        async::parallel_for(async::irange(0, 5), [](int x) {
            std::cout << x;
        });
        std::cout << std::endl;
    
        int r = async::parallel_reduce({1, 2, 3, 4}, 0, [](int x, int y) {
            return x + y;
        });
        std::cout << "The sum of {1, 2, 3, 4} is " << r << std::endl;
    
        MainWindow w;
        w.show();
    
        return a.exec();
    }
    
    

    the window wouldn't show, and error message are:

    terminate called without an active exception
    terminate called recursively
    terminate called recursively
    

    how to run some tasks behind Window UI?

  • arm gcc 4.8 error

    arm gcc 4.8 error

    /opt/arm-2014/arm-2014.05//bin/arm-none-linux-gnueabi-g++ -DLIBASYNC_STATIC -isystem /home/cyc/oscmake/3rdparty/asyncplusplus/include -g -std=gnu++11 -o CMakeFiles/asyncplusplus.out.dir/src/asyncplusplus.cpp.o -c /home/cyc/oscmake/src/asyncplusplus.cpp [build] /usr/bin/make -f CMakeFiles/serial.out.dir/build.make CMakeFiles/serial.out.dir/depend [build] make[2]: Entering directory '/home/cyc/oscmake/build' [build] cd /home/cyc/oscmake/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/cyc/oscmake /home/cyc/oscmake /home/cyc/oscmake/build /home/cyc/oscmake/build /home/cyc/oscmake/build/CMakeFiles/serial.out.dir/DependInfo.cmake --color= [build] make[2]: Leaving directory '/home/cyc/oscmake/build' [build] /usr/bin/make -f CMakeFiles/serial.out.dir/build.make CMakeFiles/serial.out.dir/build [build] make[2]: Entering directory '/home/cyc/oscmake/build' [build] make[2]: Nothing to be done for 'CMakeFiles/serial.out.dir/build'. [build] make[2]: Leaving directory '/home/cyc/oscmake/build' [build] [ 90%] Built target serial.out [build] In file included from /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++.h:141:0, [build] from /home/cyc/oscmake/src/asyncplusplus.cpp:2: [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:55:34: error: 'std::exception_ptr' has not been declared [build] void (cancel)(task_base, std::exception_ptr&&) LIBASYNC_NOEXCEPT; [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h: In member function 'void async::detail::task_base::run_continuation(Sched&, async::detail::task_ptr&&)': [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:104:37: error: 'current_exception' is not a member of 'std' [build] cont->vtable->cancel(cont.get(), std::current_exception()); [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h: At global scope: [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:170:31: error: 'exception_ptr' is not a member of 'std' [build] std::aligned_storage<sizeof(std::exception_ptr), std::alignment_ofstd::exception_ptr::value>::type except; [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:170:70: error: 'exception_ptr' is not a member of 'std' [build] std::aligned_storage<sizeof(std::exception_ptr), std::alignment_ofstd::exception_ptr::value>::type except; [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:170:70: error: 'exception_ptr' is not a member of 'std' [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:170:88: error: template argument 1 is invalid [build] std::aligned_storage<sizeof(std::exception_ptr), std::alignment_ofstd::exception_ptr::value>::type except; [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:170:96: error: template argument 1 is invalid [build] std::aligned_storage<sizeof(std::exception_ptr), std::alignment_ofstd::exception_ptr::value>::type except; [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:170:96: error: template argument 2 is invalid [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:170:99: error: expected ';' at end of member declaration [build] std::aligned_storage<sizeof(std::exception_ptr), std::alignment_ofstd::exception_ptr::value>::type except; [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:170:104: error: 'except' does not name a type [build] std::aligned_storage<sizeof(std::exception_ptr), std::alignment_ofstd::exception_ptr::value>::type except; [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:211:31: error: 'exception_ptr' is not a member of 'std' [build] std::aligned_storage<sizeof(std::exception_ptr), std::alignment_ofstd::exception_ptr::value>::type except; [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:211:70: error: 'exception_ptr' is not a member of 'std' [build] std::aligned_storage<sizeof(std::exception_ptr), std::alignment_ofstd::exception_ptr::value>::type except; [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:211:70: error: 'exception_ptr' is not a member of 'std' [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:211:88: error: template argument 1 is invalid [build] std::aligned_storage<sizeof(std::exception_ptr), std::alignment_ofstd::exception_ptr::value>::type except; [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:211:96: error: template argument 1 is invalid [build] std::aligned_storage<sizeof(std::exception_ptr), std::alignment_ofstd::exception_ptr::value>::type except; [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:211:96: error: template argument 2 is invalid [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:211:99: error: expected ';' at end of member declaration [build] std::aligned_storage<sizeof(std::exception_ptr), std::alignment_ofstd::exception_ptr::value>::type except; [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:211:104: error: 'except' does not name a type [build] std::aligned_storage<sizeof(std::exception_ptr), std::alignment_ofstd::exception_ptr::value>::type except; [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:236:31: error: 'exception_ptr' is not a member of 'std' [build] std::aligned_storage<sizeof(std::exception_ptr), std::alignment_ofstd::exception_ptr::value>::type except; [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:236:70: error: 'exception_ptr' is not a member of 'std' [build] std::aligned_storage<sizeof(std::exception_ptr), std::alignment_ofstd::exception_ptr::value>::type except; [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:236:70: error: 'exception_ptr' is not a member of 'std' [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:236:88: error: template argument 1 is invalid [build] std::aligned_storage<sizeof(std::exception_ptr), std::alignment_ofstd::exception_ptr::value>::type except; [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:236:96: error: template argument 1 is invalid [build] std::aligned_storage<sizeof(std::exception_ptr), std::alignment_ofstd::exception_ptr::value>::type except; [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:236:96: error: template argument 2 is invalid [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:236:99: error: expected ';' at end of member declaration [build] std::aligned_storage<sizeof(std::exception_ptr), std::alignment_ofstd::exception_ptr::value>::type except; [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:236:104: error: 'except' does not name a type [build] std::aligned_storage<sizeof(std::exception_ptr), std::alignment_ofstd::exception_ptr::value>::type except; [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:274:24: error: 'std::exception_ptr' has not been declared [build] void cancel_base(std::exception_ptr&& except_) [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:282:26: error: 'std::exception_ptr' has not been declared [build] void set_exception(std::exception_ptr&& except_) [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:288:2: error: 'exception_ptr' in namespace 'std' does not name a type [build] std::exception_ptr& get_exception() [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h: In destructor 'async::detail::task_result::~task_result()': [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:270:21: error: expected type-specifier [build] reinterpret_caststd::exception_ptr*(&this->except)->~exception_ptr(); [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:270:21: error: expected '>' [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:270:21: error: expected '(' [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:270:21: error: 'exception_ptr' is not a member of 'std' [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:270:40: error: expected primary-expression before '>' token [build] reinterpret_caststd::exception_ptr*(&this->except)->~exception_ptr(); [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:270:74: error: expected ')' before ';' token [build] reinterpret_caststd::exception_ptr*(&this->except)->~exception_ptr(); [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h: In member function 'void async::detail::task_result::set_exception(int&&)': [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:284:22: error: expected type-specifier [build] new(&this->except) std::exception_ptr(std::move(except_)); [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:284:22: error: expected ';' [build] In file included from /home/cyc/oscmake/src/asyncplusplus.cpp:2:0: [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h: In member function 'void async::detail::task_result::wait_and_throw()': [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:297:4: error: 'rethrow_exception' is not a member of 'std' [build] LIBASYNC_RETHROW_EXCEPTION(get_exception()); [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:297:4: error: there are no arguments to 'get_exception' that depend on a template parameter, so a declaration of 'get_exception' must be available [-fpermissive] [build] LIBASYNC_RETHROW_EXCEPTION(get_exception()); [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:297:4: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated) [build] In file included from /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++.h:141:0, [build] from /home/cyc/oscmake/src/asyncplusplus.cpp:2: [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h: At global scope: [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:405:40: error: 'std::exception_ptr' has not been declared [build] static void cancel(task_base* t, std::exception_ptr&& except) LIBASYNC_NOEXCEPT [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h: In static member function 'static void async::detail::task_func<Sched, Func, Result>::run(async::detail::task_base*)': [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:400:14: error: 'current_exception' is not a member of 'std' [build] cancel(t, std::current_exception()); [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h: In member function 'void async::detail::unwrapped_func<Result, Child>::operator()(Child) const': [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:473:25: error: 'exception_ptr' is not a member of 'std' [build] parent->cancel_base(std::exception_ptr(get_internal_task(child_task)->get_exception())); [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:477:24: error: 'current_exception' is not a member of 'std' [build] parent->cancel_base(std::current_exception()); [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h: In function 'void async::detail::unwrapped_finish(async::detail::task_base*, Child)': [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:495:63: error: 'current_exception' is not a member of 'std' [build] static_cast<task_result>(parent_base)->cancel_base(std::current_exception()); [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h: In member function 'void async::detail::continuation_exec_func<Sched, Parent, Result, Func, std::integral_constant<bool, true>, false>::operator()(async::detail::task_base)': [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:548:64: error: 'exception_ptr' is not a member of 'std' [build] task_func<Sched, continuation_exec_func, Result>::cancel(t, std::exception_ptr(get_internal_task(parent)->get_exception())); [build] ^ [build] In file included from /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++.h:141:0, [build] from /home/cyc/oscmake/src/asyncplusplus.cpp:2: [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h: In member function 'void async::detail::continuation_exec_func<Sched, Parent, Result, Func, async::detail::fake_void, false>::operator()(async::detail::task_base*)': [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:565:64: error: 'exception_ptr' is not a member of 'std' [build] task_func<Sched, continuation_exec_func, Result>::cancel(t, std::exception_ptr(get_internal_task(parent)->get_exception())); [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h: In member function 'void async::detail::continuation_exec_func<Sched, Parent, Result, Func, std::integral_constant<bool, true>, true>::operator()(async::detail::task_base*)': [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:593:64: error: 'exception_ptr' is not a member of 'std' [build] task_func<Sched, continuation_exec_func, Result>::cancel(t, std::exception_ptr(get_internal_task(parent)->get_exception())); [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h: In member function 'void async::detail::continuation_exec_func<Sched, Parent, Result, Func, async::detail::fake_void, true>::operator()(async::detail::task_base*)': [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task_base.h:607:64: error: 'exception_ptr' is not a member of 'std' [build] task_func<Sched, continuation_exec_func, Result>::cancel(t, std::exception_ptr(get_internal_task(parent)->get_exception())); [build] ^ [build] In file included from /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++.h:142:0, [build] from /home/cyc/oscmake/src/asyncplusplus.cpp:2: [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/scheduler.h: In destructor 'async::task_run_handle::~task_run_handle()': [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/scheduler.h:121:41: error: 'make_exception_ptr' is not a member of 'std' [build] handle->vtable->cancel(handle.get(), std::make_exception_ptr(task_not_executed())); [build] ^ [build] In file included from /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++.h:143:0, [build] from /home/cyc/oscmake/src/asyncplusplus.cpp:2: [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task.h: At global scope: [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task.h:118:2: error: 'exception_ptr' in namespace 'std' does not name a type [build] std::exception_ptr get_exception() const [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task.h:218:26: error: 'std::exception_ptr' has not been declared [build] bool set_exception(std::exception_ptr except) const [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task.h: In member function 'bool async::detail::basic_event::set_internal(T&&) const': [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task.h:166:42: error: 'current_exception' is not a member of 'std' [build] get_internal_task(*this)->cancel_base(std::current_exception()); [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task.h: In destructor 'async::detail::basic_event::~basic_event()': [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task.h:197:18: error: 'make_exception_ptr' is not a member of 'std' [build] set_exception(std::make_exception_ptr(abandoned_event_task())); [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task.h: At global scope: [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task.h:466:2: error: 'exception_ptr' in namespace 'std' does not name a type [build] std::exception_ptr get_exception() const [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task.h:545:34: error: template declaration of 'async::task async::make_exception_task' [build] task make_exception_task(std::exception_ptr except) [build] ^ [build] /home/cyc/oscmake/3rdparty/asyncplusplus/include/async++/task.h:545:29: error: 'exception_ptr' is not a member of 'std' [build] task make_exception_task(std::exception_ptr except) [build] ^ [build] make[2]: *** [CMakeFiles/asyncplusplus.out.dir/build.make:66: CMakeFiles/asyncplusplus.out.dir/src/asyncplusplus.cpp.o] Error 1 [build] make[2]: Leaving directory '/home/cyc/oscmake/build' [build] make[1]: Leaving directory '/home/cyc/oscmake/build' [build] make[1]: *** [CMakeFiles/Makefile2:679: CMakeFiles/asyncplusplus.out.dir/all] Error 2 [build] make: *** [Makefile:120: all] Error 2 [build] Build finished with exit code 2

    $ /opt/arm-2014/arm-2014.05//bin/arm-none-linux-gnueabi-g++ -vUsing built-in specs. COLLECT_GCC=/opt/arm-2014/arm-2014.05//bin/arm-none-linux-gnueabi-g++ COLLECT_LTO_WRAPPER=/opt/arm-2014/arm-2014.05/bin/../libexec/gcc/arm-none-linux-gnueabi/4.8.3/lto-wrapper Target: arm-none-linux-gnueabi Configured with: /scratch/maciej/arm-linux-2014.05-rel/src/gcc-4.8-2014.05/configure --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --target=arm-none-linux-gnueabi --enable-threads --disable-libmudflap --disable-libssp --disable-libstdcxx-pch --enable-extra-sgxxlite-multilibs --with-arch=armv5te --with-gnu-as --with-gnu-ld --with-specs='%{save-temps: -fverbose-asm} %{funwind-tables|fno-unwind-tables|mabi=*|ffreestanding|nostdlib:;:-funwind-tables} -D__CS_SOURCERYGXX_MAJ__=2014 -D__CS_SOURCERYGXX_MIN__=5 -D__CS_SOURCERYGXX_REV__=29' --enable-languages=c,c++ --enable-shared --enable-lto --enable-symvers=gnu --enable-__cxa_atexit --with-pkgversion='Sourcery CodeBench Lite 2014.05-29' --with-bugurl=https://sourcery.mentor.com/GNUToolchain/ --disable-nls --prefix=/opt/codesourcery --with-sysroot=/opt/codesourcery/arm-none-linux-gnueabi/libc --with-build-sysroot=/scratch/maciej/arm-linux-2014.05-rel/install/opt/codesourcery/arm-none-linux-gnueabi/libc --with-gmp=/scratch/maciej/arm-linux-2014.05-rel/obj/pkg-2014.05-29-arm-none-linux-gnueabi/arm-2014.05-29-arm-none-linux-gnueabi.extras/host-libs-i686-pc-linux-gnu/usr --with-mpfr=/scratch/maciej/arm-linux-2014.05-rel/obj/pkg-2014.05-29-arm-none-linux-gnueabi/arm-2014.05-29-arm-none-linux-gnueabi.extras/host-libs-i686-pc-linux-gnu/usr --with-mpc=/scratch/maciej/arm-linux-2014.05-rel/obj/pkg-2014.05-29-arm-none-linux-gnueabi/arm-2014.05-29-arm-none-linux-gnueabi.extras/host-libs-i686-pc-linux-gnu/usr --with-isl=/scratch/maciej/arm-linux-2014.05-rel/obj/pkg-2014.05-29-arm-none-linux-gnueabi/arm-2014.05-29-arm-none-linux-gnueabi.extras/host-libs-i686-pc-linux-gnu/usr --with-cloog=/scratch/maciej/arm-linux-2014.05-rel/obj/pkg-2014.05-29-arm-none-linux-gnueabi/arm-2014.05-29-arm-none-linux-gnueabi.extras/host-libs-i686-pc-linux-gnu/usr --disable-libgomp --disable-libitm --enable-libatomic --disable-libssp --enable-poison-system-directories --with-build-time-tools=/scratch/maciej/arm-linux-2014.05-rel/install/opt/codesourcery/arm-none-linux-gnueabi/bin --with-build-time-tools=/scratch/maciej/arm-linux-2014.05-rel/install/opt/codesourcery/arm-none-linux-gnueabi/bin SED=sed Thread model: posix gcc version 4.8.3 20140320 (prerelease) (Sourcery CodeBench Lite 2014.05-29)

    [email protected] ~/oscmake master $

  • need more examples of Composition

    need more examples of Composition

    Wiki mentioned basic examples of each feature with static array of task. Can we get more examples such as how to create dynamic list of tasks and use when_all().

  • thread wainting for task to end should not run another task

    thread wainting for task to end should not run another task

    Hello, thank you for the nice lib.

    I will try to describe my problem. The default scheduler runs several tasks, says A and B Task A creates a temporary scheduler and wait on it's internal tasks with when_all(A_tasks).wait() The waiting thread runs task B and this leads to a mess as B cannot be called from A. A thread waiting for a task to end should not run another task.

  • Can you add more support for when_all, when_any, when_seq and fail?

    Can you add more support for when_all, when_any, when_seq and fail?

    Can you add more support for when_all, when_any, when_seq and fail? Similar to this open source project: https://github.com/Naios/continuable https://naios.github.io/continuable/

Laughably simple Actor concurrency framework for C++20

Light Actor Framework Concurrency is a breeze. Also a nightmare, if you ever used synchronization techniques. Mostly a nightmare, though. This tiny li

Sep 11, 2022
Open source PHP extension for Async IO, Coroutines and Fibers

Swoole is an event-driven asynchronous & coroutine-based concurrency networking communication engine with high performance written in C++ for PHP. Ope

Dec 3, 2022
Async GRPC with C++20 coroutine support

agrpc Build an elegant GRPC async interface with C++20 coroutine and libunifex (target for C++23 executor). Get started mkdir build && cd build conan

Nov 15, 2022
Nov 30, 2022
The C++ Standard Library for Parallelism and Concurrency

Documentation: latest, development (master) HPX HPX is a C++ Standard Library for Concurrency and Parallelism. It implements all of the corresponding

Nov 29, 2022
The libdispatch Project, (a.k.a. Grand Central Dispatch), for concurrency on multicore hardware

Grand Central Dispatch Grand Central Dispatch (GCD or libdispatch) provides comprehensive support for concurrent code execution on multicore hardware.

Dec 1, 2022
Go-style concurrency in C

LIBMILL Libmill is a library that introduces Go-style concurrency to C. Documentation For the documentation check the project website: http://libmill.

Nov 29, 2022
A header-only C++ library for task concurrency
A header-only C++ library for task concurrency

transwarp Doxygen documentation transwarp is a header-only C++ library for task concurrency. It allows you to easily create a graph of tasks where eve

Nov 23, 2022
Modern concurrency for C++. Tasks, executors, timers and C++20 coroutines to rule them all

concurrencpp, the C++ concurrency library concurrencpp is a tasking library for C++ allowing developers to write highly concurrent applications easily

Dec 2, 2022
HPX is a C++ Standard Library for Concurrency and Parallelism

HPX is a C++ Standard Library for Concurrency and Parallelism. It implements all of the corresponding facilities as defined by the C++ Standard. Additionally, in HPX we implement functionalities proposed as part of the ongoing C++ standardization process. We also extend the C++ Standard APIs to the distributed case.

Nov 28, 2022
Complementary Concurrency Programs for course "Linux Kernel Internals"

Complementary Programs for course "Linux Kernel Internals" Project Listing tpool: A lightweight thread pool. tinync: A tiny nc implementation using co

Nov 18, 2022
Yet Another Concurrency Library

YACLib YACLib (Yet Another Concurrency Library) is a C++ library for concurrent tasks execution. Documentation Install guide About dependencies Target

Dec 2, 2022
Task System presented in "Better Code: Concurrency - Sean Parent"
Task System presented in

task_system task_system provides a task scheduler for modern C++. The scheduler manages an array of concurrent queues A task, when scheduled, is enque

Sep 14, 2022
Deadlockempire.github.io - The Deadlock Empire: Slay dragons, learn concurrency!

The Deadlock Empire A game that teaches locking and concurrency. It runs on https://deadlockempire.github.io. Contributing We gladly welcome all contr

Nov 17, 2022
Libgo - Go-style concurrency in C++11
Libgo - Go-style concurrency in C++11

libgo libgo -- a coroutine library and a parallel Programming Library Libgo is a stackful coroutine library for collaborative scheduling written in C+

Nov 28, 2022
The RaftLib C++ library, streaming/dataflow concurrency via C++ iostream-like operators

RaftLib is a C++ Library for enabling stream/data-flow parallel computation. Using simple right shift operators (just like the C++ streams that you wo

Dec 5, 2022
A task scheduling framework designed for the needs of game developers.

Intel Games Task Scheduler (GTS) To the documentation. Introduction GTS is a C++ task scheduling framework for multi-processor platforms. It is design

Nov 26, 2022
An implementation of Actor, Publish-Subscribe, and CSP models in one rather small C++ framework. With performance, quality, and stability proved by years in the production.
An implementation of Actor, Publish-Subscribe, and CSP models in one rather small C++ framework. With performance, quality, and stability proved by years in the production.

What is SObjectizer? What distinguishes SObjectizer? SObjectizer is not like TBB, taskflow or HPX Show me the code! HelloWorld example Ping-Pong examp

Nov 15, 2022
High Performance Linux C++ Network Programming Framework based on IO Multiplexing and Thread Pool

Kingpin is a C++ network programming framework based on TCP/IP + epoll + pthread, aims to implement a library for the high concurrent servers and clie

Oct 19, 2022