tconcurrent is a coroutine library that allows writing asynchronous code that is both C++14 and coroutines-TS-compatible.
The coroutines are stackful when compiled in C++14 mode and stackless when using the coroutines-TS mode.
tconcurrent exposes an async_resumable
function that will run a coroutine
asynchronously. A coroutine function must return a tc::cotask
and can then use
the TC_AWAIT
and TC_RETURN
macros.
int main()
{
// Run an asynchronous task, like `std::async`
tc::future<std::string> f1 = tc::async([]() -> std::string {
return "42";
});
// Run a resumable asynchronous task
tc::future<int> f2 = tc::async_resumable([]() -> tc::cotask<int> {
int const val = TC_AWAIT(receive_value());
TC_AWAIT(send_value(val * 2));
TC_RETURN(42);
});
f1.get();
f2.get();
}
We are actively working to allow external developers to build and test this SDK from its source.
To generate and open documentation:
$ cd doc && doxygen && xdg-open build/html/index.html
To better understand how tconcurrent works, a big picture explanation is here:
We welcome feedback. Feel free to open any issue on the Github bug tracker.
The tconcurrent library is licensed under the Apache License, version 2.0.