Computer Scientist

Friday, 3 December 2010

Dive into more details of sfslite which is used by Chord official implementation

I decided to give up the usage of Openchord because it is quite difficult to use. I will back to Chord Official implementation.

Here I refresh some knowledge of sfslite and provide some useful web pages to understanding its code.








:
    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::ref ).
      wrap(hello) provides a callback version of hello() method to function docallback( callcallback::ref ) as docallback(callback::ref)'s parameter.
      wrap(docallback, wrap(hello)) provides a callback version of docallback(callback::ref) to delaycb and asks delaycb() to register docallback(callback::ref) in event queue.

      ========Bear in mind, the return value of wrap() is callback::ref=========

      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.