Type-Safe Eventful Sessions in Java

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 eventhandling 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.

[1]  Pierre America,et al.  ECOOP'91 European Conference on Object-Oriented Programming , 1991, Lecture Notes in Computer Science.

[2]  Kohei Honda,et al.  An Interaction-based Language and its Typing System , 1994, PARLE.

[3]  Luca Cardelli,et al.  Modern concurrency abstractions for C# , 2002, TOPL.

[4]  Michael F. P. O'Boyle A Data Partitioning Algorithm for Distributed Memory Compilation , 1994, PARLE.

[5]  Patrick Th. Eugster,et al.  EventJava: An Extension of Java for Event Correlation , 2009, ECOOP.

[6]  Brian Campbell,et al.  Amortised Memory Analysis Using the Depth of Data Structures , 2009, ESOP.

[7]  P. Cochat,et al.  Et al , 2008, Archives de pediatrie : organe officiel de la Societe francaise de pediatrie.

[8]  Marsha Chechik,et al.  CONCUR 2008 - Concurrency Theory, 19th International Conference, CONCUR 2008, Toronto, Canada, August 19-22, 2008. Proceedings , 2008, CONCUR.

[9]  Marvin Theimer,et al.  Cooperative Task Management Without Manual Stack Management , 2002, USENIX Annual Technical Conference, General Track.

[10]  Nobuko Yoshida,et al.  Session-Based Distributed Programming in Java , 2008, ECOOP.

[11]  Maxwell N. Krohn,et al.  Building Secure High-Performance Web Services with OKWS , 2004, USENIX Annual Technical Conference, General Track.

[12]  Simon J. Gay,et al.  Subtyping for session types in the pi calculus , 2005, Acta Informatica.

[13]  António Ravara,et al.  Modular session types for distributed object-oriented programming , 2010, POPL '10.

[14]  Cosimo Laneve,et al.  Inheritance in the join calculus , 2000, J. Log. Algebraic Methods Program..

[15]  Loris D'Antoni,et al.  Global Progress in Dynamically Interleaved Multiparty Sessions , 2008, CONCUR.

[16]  Mario Tokoro,et al.  An Object Calculus for Asynchronous Communication , 1991, ECOOP.

[17]  James R. Larus,et al.  Language support for fast and reliable message-based communication in singularity OS , 2006, EuroSys.

[18]  David E. Culler,et al.  The nesC language: A holistic approach to networked embedded systems , 2003, PLDI '03.

[19]  Dave Thomas,et al.  ECOOP 2006 - Object-Oriented Programming , 2006 .

[20]  David E. Culler,et al.  SEDA: an architecture for well-conditioned, scalable internet services , 2001, SOSP.

[21]  Jan Vitek,et al.  ECOOP 2008 - Object-Oriented Programming, 22nd European Conference, Paphos, Cyprus, July 7-11, 2008, Proceedings , 2008, ECOOP.

[22]  Eric A. Brewer,et al.  USENIX Association Proceedings of HotOS IX : The 9 th Workshop on Hot Topics in Operating Systems , 2003 .

[23]  Mario Bravetti,et al.  CONCUR 2009 - Concurrency Theory, 20th International Conference, CONCUR 2009, Bologna, Italy, September 1-4, 2009. Proceedings , 2009, CONCUR.

[24]  George C. Necula,et al.  Capriccio: scalable threads for internet services , 2003, SOSP '03.

[25]  Sophia Drossopoulou,et al.  Session Types for Object-Oriented Languages , 2006, ECOOP.

[26]  John C. Klensin,et al.  Simple Mail Transfer Protocol , 2001, RFC.

[27]  Nobuko Yoshida,et al.  Session-Based Communication Optimisation for Higher-Order Mobile Processes , 2009, TLCA.

[28]  Martín Abadi,et al.  Dynamic typing in polymorphic languages , 1995, Journal of Functional Programming.

[29]  John R. Douceur,et al.  Cooperative Task Management without Manual Stack Management or, Event-driven Programming is Not the Opposite of Threaded Programming , 2002 .

[30]  Eddie Kohler,et al.  Making Events Less Slippery with eel , 2005, HotOS.

[31]  Hari Balakrishnan,et al.  An end-to-end approach to host mobility , 2000, MobiCom '00.

[32]  Sam Lindley,et al.  Extensional Rewriting with Sums , 2007, TLCA.

[33]  Vasco Thudichum Vasconcelos,et al.  Language Primitives and Type Discipline for Structured Communication-Based Programming Revisited: Two Systems for Higher-Order Session Communication , 1998, SecReT@ICALP.

[34]  Roger M. Needham,et al.  On the duality of operating system structures , 1979, OPSR.

[35]  Eddie Kohler,et al.  Events Can Make Sense , 2007, USENIX Annual Technical Conference.

[36]  Peng Li,et al.  Combining events and threads for scalable network services implementation and evaluation of monadic, application-level concurrency primitives , 2007, PLDI '07.

[37]  Luca Padovani,et al.  Contracts for Mobile Processes , 2009, CONCUR.

[38]  Hugo Torres Vieira,et al.  Conversation types , 2009, Theor. Comput. Sci..

[39]  Luca Padovani,et al.  Foundations of session types , 2009, PPDP '09.

[40]  Martin Odersky,et al.  Scala Actors: Unifying thread-based and event-based programming , 2009, Theor. Comput. Sci..

[41]  Martín Abadi,et al.  Dynamic typing in a statically-typed language , 1989, POPL '89.