News for hackers. Stuff that matters.
Re:It ain't about the callbacks, it's about the flow control by Sidnicious on Thursday September 05, 2013 @01:34PM (#6335557)
I'm working on a library for C++ called Team where this kind of flow control is possible. At its core it's got coroutines, so you can write code in a blocking style.

The current (early!) socket APIs can all be called with a callback (which act like Node and call it as fast as possible), or without one (in which case they block). Here's an echo server that accepts connections as fast as possible, but does blocking reads and writes so only one chunk per client gets buffered at a time:

https://github.com/Sidnicious/team/blob/b157ea2c58177a2587c9...

The callbacks-as-fast-as-possible version is just implemented on top of the blocking one, so it'd be trivial to add flow control via a blocking callback (or by calling `accept()` in blocking style and making your own decision about when to call it again):

https://github.com/Sidnicious/team/blob/b157ea2c58177a2587c9...

There are no comments on this comment yet.