Here I refresh some knowledge of sfslite and provide some useful web pages to understanding its code.
[Main Page]: http://www.okws.org/doku.php?id=sfslite
[Overview of sfslite]: http://www.okws.org/doku.php?id=sfslite:overview
[Some examples of usage]: http://www.okws.org/doku.php?id=sfslite:qhash
[async Tutorial]: http://pdos.csail.mit.edu/6.824-2004/async/
[Tips of using]: http://www.okws.org/doku.php?id=sfslite:tips
[Installation Guide]: http://www.okws.org/doku.php?id=sfslite:install
One thing that is a little difficult to understand is in the Lesson 3: more than one callback are in the same procedure.
Line 27 and 28 can be merged into "delaycb (1, 0, wrap(docallback, wrap(hello)));"
I think I could understand it like this:
each wrap() will produce a callback version of a function (type of callback
wrap(hello) provides a callback version of hello() method to function docallback( callcallback
wrap(docallback, wrap(hello)) provides a callback version of docallback(callback
========Bear in mind, the return value of wrap() is callback
Here is the graphical expression of this mechanism:
The usages of callback (callback::ref):
(1). it can be passed into a callback function like docallback as its parameter and be invoked in this callback function cb();
(2). it can be registered by a underlaying mechanism like delaycb.