The F# Asynchronous Programming Model

  • Don Syme
  • Tomas Petricek
  • Dmitry Lomov
Part of the Lecture Notes in Computer Science book series (LNCS, volume 6539)

Abstract

We describe the asynchronous programming model in F#, and its applications to reactive, parallel and concurrent programming. The key feature combines a core language with a non-blocking modality to author lightweight asynchronous tasks, where the modality has control flow constructs that are syntactically a superset of the core language and are given an asynchronous semantic interpretation. This allows smooth transitions between synchronous and asynchronous code and eliminates callback-style treatments of inversion of control, without disturbing the foundation of CPU-intensive programming that allows F# to interoperate smoothly and compile efficiently. An adapted version of this approach has recently been announced for a future version of C#.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Agha, G.: Actors: a model of concurrent computation in distributed systems. MIT Press, Cambridge (1986)Google Scholar
  2. 2.
    Baumann, A.: et al.: The multikernel: a new OS architecture for scalable multicore systems. In: SOSP 2009: Proc. of the ACM SIGOPS 22nd Symp. on OS Principles (2009)Google Scholar
  3. 3.
    von Behren, R., Condit, J., Brewer, E.: Why events are a bad idea (for high-concurrency servers). In: HOTOS 2003: Proc. of the 9th Conf. on Hot Topics in OS (2003)Google Scholar
  4. 4.
    Berry, G., Gonthier, G.: The ESTEREL synchronous programming language: design, semantics, implementation. Sci. Comput. Program. 19(2), 87–152 (1992)MATHCrossRefGoogle Scholar
  5. 5.
    Friedman, D.P., Wise, D.S.: Aspects of applicative programming for parallel processing. IEEE Trans. Computers 27(4), 289–296 (1978)MATHCrossRefGoogle Scholar
  6. 6.
    Haller, P., Odersky, M.: Scala actors: Unifying thread-based and event-based programming. Theor. Comput. Sci. 410(2-3), 202–220 (2009)MATHCrossRefMathSciNetGoogle Scholar
  7. 7.
    Kiselyov, O.: Delimited control in OCaml, abstractly and concretely. In: Blume, M., Kobayashi, N., Vidal, G. (eds.) FLOPS 2010. LNCS, vol. 6009, pp. 304–320. Springer, Heidelberg (2010)CrossRefGoogle Scholar
  8. 8.
    Lauer, H.C., Needham, R.M.: On the duality of operating system structures. SIGOPS Oper. Syst. Rev. 13(2), 3–19 (1979)CrossRefGoogle Scholar
  9. 9.
    Li, P., Zdancewic, S.: Combining events and threads for scalable network services implementation. SIGPLAN Not. 42(6), 189–199 (2007)CrossRefGoogle Scholar
  10. 10.
    McNamara, B.: F# async on the server side (March 2010), http://tinyurl.com/fsasyncserver (retrieved 5/9/2010)
  11. 11.
    Meijer, E., Beckman, B., Bierman, G.: LINQ: reconciling object, relations and XML in the.NET framework. In: SIGMOD 2006: Int. ACM Conf. on Mgmt. of Data. ACM, New York (2006)Google Scholar
  12. 12.
    Odersky, M., Spoon, L., Venners, B.: Programming in Scala, Artima, USA (2008)Google Scholar
  13. 13.
    Petricek, T., Skeet, J.: Real World Functional Programming: With Examples in F# and C#. Manning, USA (2009)Google Scholar
  14. 14.
    Rompf, T., Maier, I., Odersky, M.: Implementing first-class polymorphic delimited continuations by a type-directed selective CPS-transform. In: ICFP 2009: Proc. of the 14th ACM SIGPLAN Int. Conf. on Func. Prog. (2009)Google Scholar
  15. 15.
    Srinivasan, S.: Kilim: A Server Framework with Lightweight Actors, Isolation Types & Zero-copy Messaging. Ph.D. thesis, University of Cambridge (2010) Google Scholar
  16. 16.
    Srinivasan, S., Mycroft, A.: Kilim: Isolation-typed actors for java. In: Ryan, M. (ed.) ECOOP 2008. LNCS, vol. 5142, pp. 104–128. Springer, Heidelberg (2008)CrossRefGoogle Scholar
  17. 17.
    Syme, D.: F# 2.0 Language Specification, http://tinyurl.com/fsspec
  18. 18.
    Syme, D.: Simplicity and compositionality in asynchronous programming through first class events (March 2006), http://tinyurl.com/composingevents, (retrieved: January 2010)
  19. 19.
    Syme, D., Granicz, A., Cisternino, A.: Expert F#. Apress (2007)Google Scholar
  20. 20.
    Virding, R., et al.: Concurrent programming in ERLANG, 2nd edn. Prentice Hall, Englewood Cliffs (1996)Google Scholar
  21. 21.
    Vouillon, J.: OCaml light weight threading library (2002), http://ocsigen.org/lwt/
  22. 22.
    Wehrman, I., Kitchin, D., Cook, W.R., Misra, J.: A timed semantics of Orc. Theor. Comput. Sci. 402, 234–248 (2008)MATHCrossRefMathSciNetGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2011

Authors and Affiliations

  • Don Syme
    • 1
  • Tomas Petricek
    • 2
  • Dmitry Lomov
    • 3
  1. 1.Microsoft ResearchCambridgeUnited Kingdom
  2. 2.Faculty of Mathematics and PhysicsCharles UniversityPragueCzech Republic
  3. 3.Microsoft CorporationRedmondUSA

Personalised recommendations