Pause ’n’ Play: Formalizing Asynchronous C\(^\sharp\)

  • Gavin Bierman
  • Claudio Russo
  • Geoffrey Mainland
  • Erik Meijer
  • Mads Torgersen
Part of the Lecture Notes in Computer Science book series (LNCS, volume 7313)

Abstract

Writing applications that connect to external services and yet remain responsive and resource conscious is a difficult task. With the rise of web programming this has become a common problem. The solution lies in using asynchronous operations that separate issuing a request from waiting for its completion. However, doing so in common object-oriented languages is difficult and error prone. Asynchronous operations rely on callbacks, forcing the programmer to cede control. This inversion of control-flow impedes the use of structured control constructs, the staple of sequential code. In this paper, we describe the language support for asynchronous programming in the upcoming version of C\(^\sharp\). The feature enables asynchronous programming using structured control constructs. Our main contribution is a precise mathematical description that is abstract (avoiding descriptions of compiler-generated state machines) and yet sufficiently concrete to allow important implementation properties to be identified and proved correct.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Adya, A., Howell, J., Theimer, M., Bolosky, W.J., Douceur, J.R.: Cooperative task management without manual stack management. In: Proceedings of USENIX (2002)Google Scholar
  2. 2.
    Bierman, G., Meijer, E., Torgersen, M.: Lost in translation: Formalizing proposed extensions to C\(^{\sharp}\). In: Proceedings of OOPSLA (2007)Google Scholar
  3. 3.
    Bierman, G., Meijer, E., Torgersen, M.: Adding Dynamic Types to C\(^\sharp\). In: D’Hondt, T. (ed.) ECOOP 2010. LNCS, vol. 6183, pp. 76–100. Springer, Heidelberg (2010)CrossRefGoogle Scholar
  4. 4.
    Bierman, G., Parkinson, M., Pitts, A.: MJ: An imperative core calculus for Java and Java with effects. Technical Report 563, University of Cambridge Computer Laboratory (2003)Google Scholar
  5. 5.
    Bruggeman, C., Waddell, O., Dybvig, R.K.: Representing control in the presence of one-shot continuations. In: Proceedings of PLDI (1996)Google Scholar
  6. 6.
    Duff, T.: Re: Explanation, please! (August 1988), USENET ArticleGoogle Scholar
  7. 7.
    Dunkels, A., Schmidt, O., Voigt, T., Ali, M.: Protothreads: Simplifying Event-Driven programming of Memory-Constrained embedded systems. In: Proceedings of SenSys (2006)Google Scholar
  8. 8.
    Fischer, J., Majumdar, R., Millstein, T.: Tasks: language support for event-driven programming. In: Proceedings of PEPM (2007)Google Scholar
  9. 9.
    Flanagan, C., Sabry, A., Duba, B., Felleisen, M.: The essence of compiling with continuations. In: Proceedings of PLDI (1993)Google Scholar
  10. 10.
    Flatt, M., Krishnamurthi, S., Felleisen, M.: A programmer’s reduction semantics for classes and mixins. Technical Report TR-97-293, Rice University (1997)Google Scholar
  11. 11.
    Haller, P., Odersky, M.: Scala actors: Unifying thread-based and event-based programming. Theoretical Computer Science 410(2-3), 202–220 (2009)MathSciNetMATHCrossRefGoogle Scholar
  12. 12.
    Hejlsberg, A., Torgersen, M., Wiltamuth, S., Golde, P.: The C\(^\sharp\) Programming Language, 4th edn. Addison-Wesley (2011)Google Scholar
  13. 13.
    Igarashi, A., Pierce, B., Wadler, P.: Featherweight Java: A minimal core calculus for Java and GJ. ACM TOPLAS 23(3), 396–450 (2001)CrossRefGoogle Scholar
  14. 14.
    Lauer, H.C., Needham, R.M.: On the duality of operating system structures. Operating Systems Review 13(2), 3–19 (1979)CrossRefGoogle Scholar
  15. 15.
    Li, P., Zdancewic, S.: Combining events and threads for scalable network services. In: Proceedings of PLDI (2007)Google Scholar
  16. 16.
    Microsoft Corporation. C# language specification for asynchronous functions (2011), http://msdn.microsoft.com/en-us/vstudio/async
  17. 17.
    Ousterhout, J.K.: Why threads are a bad idea (for most purposes). In: USENIX Winter Technical Conference, Invited Talk (June 1996)Google Scholar
  18. 18.
    Pierce, B., Turner, D.: Local type inference. In: Proceedings of POPL (1998)Google Scholar
  19. 19.
    Rompf, T., Maier, I., Odersky, M.: Implementing first-class polymorphic delimited continuations by a type-directed selective CPS-transform. In: Proceedings of ICFP (2009)Google Scholar
  20. 20.
    Syme, D., Petricek, T., Lomov, D.: The F# Asynchronous Programming Model. In: Rocha, R., Launchbury, J. (eds.) PADL 2011. LNCS, vol. 6539, pp. 175–189. Springer, Heidelberg (2011)CrossRefGoogle Scholar
  21. 21.
  22. 22.
    von Behren, R., Condit, J., Brewer, E.: Why events are a bad idea (for high-concurrency servers). In: Proceedings of HotOS (2003)Google Scholar
  23. 23.
    von Behren, R., Condit, J., Zhou, F., Necula, G.C., Brewer, E.: Capriccio: scalable threads for internet services. In: Proceedings of SOSP (2003)Google Scholar
  24. 24.
    Wand, M.: Continuation-based multiprocessing. In: Proceedings of LISP and Functional Programming (1980)Google Scholar
  25. 25.
    Welsh, M., Culler, D., Brewer, E.: SEDA: an architecture for well-conditioned, scalable internet services. In: Proceedings of SOSP (2001)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2012

Authors and Affiliations

  • Gavin Bierman
    • 1
  • Claudio Russo
    • 1
  • Geoffrey Mainland
    • 1
  • Erik Meijer
    • 2
  • Mads Torgersen
    • 3
  1. 1.Microsoft ResearchUK
  2. 2.Microsoft Corp. and TU DelftThe Netherlands
  3. 3.Microsoft CorporationUSA

Personalised recommendations