diff --git a/README.md b/README.md index 3a4e2c7..eac532c 100644 --- a/README.md +++ b/README.md @@ -553,4 +553,21 @@ sharedMes = "ping"; thread t1(pingPongFn, sharedMes); // start example with 3 concurrent threads thread t2(pingPongFn, "pong"); thread t3(pingPongFn, "boing"); +``` + +## `future` (thread support library) +```cpp +#include // Include future +function fib = // Create lambda function + [&](int i){ + if (i <= 1){ + return 1; + } + return fib(i-1) + + fib(i-2); + }; +future fut = // result of async function + async(launch::async, fib, 4); // start async function in other thread +// do some other work +cout << fut.get(); // get result of async function. Wait if needed. ``` \ No newline at end of file