Team: async C++

(.cpp) Team is a library that adds coroutines and async semantics to C++. By “async”, I mean that that when your program needs to wait for external stuff (like sending data over a network), it can work on other things at the same time. (E.g. a web server can start handling a request from one client while it waits for another to finish receiving its response). By “coroutines”, I mean independent threads of execution that can pause when they need to wait. You write code in a linear way — no callbacks. Team introduces a new keyword, async , to indicate when something should happen asynchronously with respect to the code around it. Check out this example program: #include <team> #include <iostream> using namespace std; using namespace team; void doWork() { sleep(1); } int main() { await { for (auto i : range(10)) { async { doWork(); }; } } } It takes abo...

Linked on 2014-10-08 00:22:32 | Similar Links