Easy asynchrony for C++
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples Refactor a bit Apr 29, 2015
include/team Fixes and features for localnamed May 2, 2015
.gitmodules Team no longer provides its own libuv Apr 27, 2015
README.md Fix names in the README Oct 9, 2013

README.md

Team

Event loop (libuv)-driven coroutines for C++ that are easy to use with minimal syntax. Here's an example:

#include <team/team.h>
#include <iostream>

using namespace std;
using team::sleep;

template <typename T>
void log (T s) { cout << s << endl; }

int main() {

    await {
        async { sleep(2); log("Slow thing done"); };
        log("Started a slow thing");
        async { sleep(1); log("Quick thing done"); };
        log("Started a quick thing");
    }

    log("Everything's done!");

}

It prints this:

Started a slow thing
Started a quick thing
Quick thing done
Slow thing done
Everything's done!

Calls block. async { }; runs its body in a coroutine and returns control to the caller if it blocks, or when it finishes.

await blocks until every asynchronous task spawned inside it finishes.

Status: Relatively new. Gradually becoming useful though.

I want it to work like Tame but without code transformation (except for the C++ preprocessor), and thus able to be used with libraries written in a blocking style.

Examples

You should check out these examples first:

  1. hello_world — How to run stuff asynchronously.
  2. timers — Pretty similar. Includes a fire-and-forget example.
  3. channels — Hacked-together Clojure/Go-style channels. Just proof that you can build other async constructs on top of team core. You can skip this.
  4. generators — Python-style generators with yield. Also hacked together, you can skip this.
  5. echo_server — Start it up and use one or more copies of nc to throw packets its way.

Inspiration

Notes to self