On Sun, 30 Sep 2012 23:30:40 +0200, Eldar Insafutdinov wrote:
One thing I never really understood is how you do asynchronous IO
with Go's goroutines or D's fibers. The callback model of Node.js
is pretty simple:fs.readFile(fileName, function(data) {
use(data);
});
Btw. if you want to do simulate something like this, you could do it like this:
void read(InputStream str, void delegate(in ubyte[] data) callback) )
{
conn.release();
runTask({
conn.acquire();
while( !str.empty ){
ubyte[] buf = new ubyte[conn.leastSize];
conn.read(buf);
callback(buf);
}
conn.release();
});
}
(I didn't test this so it probably contains some mistakes)