

The Joys of Affordable Concurrency - rbanffy
http://www.rounds.com/blog/joys-affordable-concurrency

======
lentil
I like the pattern in the example a lot. We recently started doing something
just like this in a Rails app at work that has to make quite a few API calls
per request. In the right circumstances it makes a big difference in response
time. Our approach was basically just this:
[https://gist.github.com/kevinmcconnell/8365521](https://gist.github.com/kevinmcconnell/8365521)

I could definitely see how using a language that makes these sorts of
operations simpler could lead to finding more cases where it's worth it.

~~~
porges
> a language that makes these sorts of operations simpler

That's essentially what async/await is doing in C# (and hopefully eventually
in C++).

For example the code in the original post could be in C# as:

    
    
        var facebookTestUser1 = CreateFacebookTestUser();
        var facebookTestUser2 = CreateFacebookTestUser();
        MakeFriends(facebookTestUser1, facebookTestUser2);
    

And asynchronously:

    
    
        var facebookTestUser1 = CreateFacebookTestUser();
        var facebookTestUser2 = CreateFacebookTestUser();
        MakeFriends(await facebookTestUser1, await facebookTestUser2);
    

Of course, the code inside CreateFacebookTestUser is going to have to change
;)

