Type-Safe Eventful Sessions in Java

  • Raymond Hu
  • Dimitrios Kouzapas
  • Olivier Pernet
  • Nobuko Yoshida
  • Kohei Honda
Part of the Lecture Notes in Computer Science book series (LNCS, volume 6183)

Abstract

Event-driven programming is a major paradigm in concurrent and communication-based programming, and a widely adopted approach to building scalable high-concurrency servers. However, traditional event-driven programs are more difficult to read, write and verify than their multi-threaded counterparts due to low-level APIs and fragmentation of control flow across disjoint event handlers. This paper presents a Java language extension and a novel type discipline for type-safe event-driven session programming that counters the problems of traditional event-based programming with abstractions and safety guarantees based on session types, while retaining the expressiveness and performance characteristics of events. The type discipline extends session types and their primitives with asynchronous input, session typecase and session set types, ensuring event-handling safety and event progress in addition to the standard type soundness and communication safety. The advantages, expressiveness and performance of event-driven session programming are demonstrated through a range of examples and benchmarks, including a session-typed SMTP server.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Abadi, M., Cardelli, L., Pierce, B.C., Plotkin, G.D.: Dynamic typing in a statically typed language. TOPLAS 13(2), 237–268 (1991)CrossRefGoogle Scholar
  2. 2.
    Adya, A., Howell, J., Theimer, M., Bolosky, W.J., Douceur, J.R.: Cooperative task management without manual stack management or, event-driven programming is not the opposite of threaded programming. In: USENIX ATC 2002, pp. 289–302. USENIX Association (2002)Google Scholar
  3. 3.
    Benton, N., Cardelli, L., Fournet, C.: Modern concurrency abstractions for C#. TOPLAS 26(5), 769–804 (2004)CrossRefGoogle Scholar
  4. 4.
    Bettini, L., et al.: Global progress in dynamically interleaved multiparty sessions. In: van Breugel, F., Chechik, M. (eds.) CONCUR 2008. LNCS, vol. 5201, pp. 418–433. Springer, Heidelberg (2008)CrossRefGoogle Scholar
  5. 5.
    Caires, L., Vieira, H.T.: Conversation types. In: Castagna, G. (ed.) ESOP 2009. LNCS, vol. 5502, pp. 285–300. Springer, Heidelberg (2009)CrossRefGoogle Scholar
  6. 6.
    Castagna, G., Padovani, L.: Contracts for mobile processes. In: Bravetti, M., Zavattaro, G. (eds.) CONCUR 2009. LNCS, vol. 5710, pp. 211–228. Springer, Heidelberg (2009)CrossRefGoogle Scholar
  7. 7.
    Dezani-Ciancaglini, M., Mostrous, D., Yoshida, N., Drossopoulou, S.: Session types for object-oriented languages. In: Thomas, D. (ed.) ECOOP 2006. LNCS, vol. 4067, pp. 328–352. Springer, Heidelberg (2006)CrossRefGoogle Scholar
  8. 8.
    Eugster, P., Jayaram, K.R.: EventJava: An extension of Java for event correlation. In: Drossopoulou, S. (ed.) ECOOP 2009. LNCS, vol. 5653, pp. 570–594. Springer, Heidelberg (2009)Google Scholar
  9. 9.
    Fähndrich, M., Aiken, M., Hawblitzel, C., Hodson, O., Hunt, G., Larus, J.R., Levi, S.: Language support for fast and reliable message-based communication in Singularity OS. In: EuroSys 2006, ACM SIGOPS, pp. 177–190. ACM, New York (2006)Google Scholar
  10. 10.
    Fournet, C., Laneve, C., Maranget, L., Rémy, D.: Inheritance in the Join calculus. JLAP 57(1-2), 23–69 (2003)MATHGoogle Scholar
  11. 11.
    Gay, S.J., Vasconcelos, V.T., Ravara, A., Gesbert, N., Caldeira, A.Z.: Modular session types for distributed object-oriented programming. In: POPL 2010, vol. 45, pp. 299–312. ACM, New York (2010)Google Scholar
  12. 12.
    Haller, P., Odersky, M.: Scala actors: Unifying thread-based and event-based programming. Theoretical Computer Science 410(2-3), 202–220 (2009)MATHCrossRefMathSciNetGoogle Scholar
  13. 13.
    Honda, K., Tokoro, M.: An object calculus for asynchronous communication. In: America, P. (ed.) ECOOP 1991. LNCS, vol. 512, pp. 133–147. Springer, Heidelberg (1991)CrossRefGoogle Scholar
  14. 14.
    Honda, K., Vasconcelos, V.T., Kubo, M.: Language primitives and type disciplines for structured communication-based programming. In: Hankin, C. (ed.) ESOP 1998. LNCS, vol. 1381, pp. 122–138. Springer, Heidelberg (1998)CrossRefGoogle Scholar
  15. 15.
    Honda, K., Yoshida, N., Carbone, M.: Multiparty asynchronous session types. In: POPL 2008, pp. 273–284. ACM, New York (2008)CrossRefGoogle Scholar
  16. 16.
    Hu, R., Yoshida, N., Honda, K.: Session-based distributed programming in Java. In: Vitek, J. (ed.) ECOOP 2008. LNCS, vol. 5142, pp. 516–541. Springer, Heidelberg (2008)CrossRefGoogle Scholar
  17. 17.
  18. 18.
    Kouzapas, D.: A session type discipline for event driven programming models. Master’s thesis, Imperial College London (2009), http://www.doc.ic.ac.uk/teaching/distinguished-projects/2010/d.kouzapas.pdf
  19. 19.
    Krohn, M.: Building secure high-performance web services with OKWS. In: USENIX ATC 2004, pp. 185–198. USENIX Association (2004)Google Scholar
  20. 20.
    Krohn, M., Kohler, E., Kaashoek, M.F.: Events can make sense. In: USENIX ATC 2007, pp. 1–14. USENIX Association (2007)Google Scholar
  21. 21.
    Lauer, H.C., Needham, R.M.: On the duality of operating system structures. SIGOPS Operating Systems Review 13(2), 3–19 (1979)CrossRefGoogle Scholar
  22. 22.
    Li, P., Zdancewic, S.: Combining events and threads for scalable network services implementation and evaluation of monadic, application-level concurrency primitives. SIGPLAN Not. 42(6), 189–199 (2007)CrossRefGoogle Scholar
  23. 23.
    Mostrous, D., Yoshida, N.: Session-based communication optimisation for higher-order mobile processes. In: Curien, P.-L. (ed.) TLCA 2009. LNCS, vol. 5608, pp. 203–218. Springer, Heidelberg (2009)CrossRefGoogle Scholar
  24. 24.
  25. 25.
  26. 26.
    The Simple Mail Transfer Protocol, http://tools.ietf.org/html/rfc5321
  27. 27.
    Snoeren, A.C., Balakrishnan, H.: An end-to-end approach to host mobility. In: MOBICOM 2000, pp. 155–166. ACM, New York (2000)CrossRefGoogle Scholar
  28. 28.
    Takeuchi, K., Honda, K., Kubo, M.: An interaction-based language and its typing system. In: Halatsis, C., Philokyprou, G., Maritsas, D., Theodoridis, S. (eds.) PARLE 1994. LNCS, vol. 817, pp. 398–413. Springer, Heidelberg (1994)Google Scholar
  29. 29.
    von Behren, R., Condit, J., Brewer, E.: Why events are a bad idea (for high-concurrency servers). In: HOTOS 2003, p. 4. USENIX Association (2003)Google Scholar
  30. 30.
    von Behren, R., Condit, J., Zhou, F., Necula, G.C., Brewer, E.: Capriccio: scalable threads for Internet services. In: SOSP 2003, pp. 268–281. ACM, New York (2003)CrossRefGoogle Scholar
  31. 31.
    Welsh, M., Culler, D.E., Brewer, E.A.: Seda: An architecture for well-conditioned, scalable Internet services. In: SOSP 2001, pp. 230–243. ACM, New York (2001)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2010

Authors and Affiliations

  • Raymond Hu
    • 1
  • Dimitrios Kouzapas
    • 1
  • Olivier Pernet
    • 1
  • Nobuko Yoshida
    • 1
  • Kohei Honda
    • 2
  1. 1.Imperial College London 
  2. 2.Queen Mary, University of London 

Personalised recommendations