Resources about Asynchronous Programming Design Patterns

前端 未结 1 532
渐次进展
渐次进展 2021-02-03 12:59

I\'m looking for non-trivial resources on concepts of asychronous programming, preferably books but also substantial articles or papers. This is not about the simple examples li

1条回答
  •  粉色の甜心
    2021-02-03 13:53

    When doing layered callbacks currying is a useful technique.

    For more on this you can look at http://en.wikibooks.org/wiki/Haskell/Higher-order_functions_and_Currying and for javascript you can look at http://www.svendtofte.com/code/curried_javascript/.

    Basically, if you have multiple layers of callbacks, rather than having one massive parameter list, you can build it up incrementally, so that when you are in a loop calling your function, the various callback functions have already been defined, and passed.

    This isn't meant as a complete answer to the question, but I was asked to put this part into an answer, so I did.

    After a quick search here is a blog where he shows using currying with callbacks:

    http://bjouhier.wordpress.com/2011/04/04/currying-the-callback-or-the-essence-of-futures/

    UPDATE:

    After reading the edit to the original question, to see design patterns for asynchronous programming, this may be a good diagram: http://www1.cse.wustl.edu/~schmidt/patterns-ace.html, but there is much more to good asynchronous design, as first-order functions will enable this to be simplified, but, if you are using the MPI library and Fortran then you will have different implementations.

    How you approach the design is affected heavily by the language and the technologies involved, that any answer will fall short of being complete.

    0 讨论(0)
提交回复
热议问题