Simpler Coordination of JavaScript Web Workers

  • Marco Krauweel
  • Sung-Shik T. Q. JongmansEmail author
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 10319)


JavaScript is a popular sequential language for implementing Web applications. To enable concurrent execution of JavaScript code, modern JavaScript engines support the Web Workers API. Using this API, developers can spawn concurrent background workers from a distinguished main worker. These workers, which run on the same machine (e.g., to exploit multicore), interact via message-passing.

The Web Workers API is relatively low-level, which makes implementing coordination protocols among background workers laborious and error-prone. To simplify this, we propose to hide the Web Workers API behind a coordination language that provides higher-level constructs. Importantly, developers already use JavaScript together with domain-specific languages HTML (for markup/structure) and CSS (for style/design); another domain-specific language (for coordination) seamlessly fits this practice. Using the coordination language Reo, we demonstrate the advantages and feasibility of this approach by example. We also present the necessary tool support (compiler; runtime library and API; front-end).


Output Port Sink Node Main Worker Promise Object FIFO Buffer 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


  1. 1.
    Javascript Web Workers Test.
  2. 2.
  3. 3.
  4. 4.
  5. 5.
  6. 6.
  7. 7.
  8. 8.
    [standard] Khronos Group: WebCL.
  9. 9.
    [standard] W3C: Web Workers.
  10. 10.
    Arbab, F.: Reo: a channel-based coordination model for component composition. Math. Struct. Comp. Sci. 14(3), 329–366 (2004)MathSciNetCrossRefzbMATHGoogle Scholar
  11. 11.
    Arbab, F.: Puff, the magic protocol. In: Agha, G., Danvy, O., Meseguer, J. (eds.) Formal Modeling: Actors, Open Systems, Biological Systems. LNCS, vol. 7000, pp. 169–206. Springer, Heidelberg (2011). doi: 10.1007/978-3-642-24933-4_9 CrossRefGoogle Scholar
  12. 12.
    Baier, C., Sirjani, M., Arbab, F., Rutten, J.: Modeling component connectors in Reo by constraint automata. Sci. Comput. Program. 61(2), 75–113 (2006)MathSciNetCrossRefzbMATHGoogle Scholar
  13. 13.
    De Koster, J., Van Cutsem, T., De Meuter, W.: 43 years of actors: a taxonomy of actor models and their key properties. In: Proceedings of AGERE 2016, pp. 31–40. ACM (2016)Google Scholar
  14. 14.
    Herhut, S., Hudson, R., Shpeisman, T., Sreeram, J.: River trail: a path to parallelism in JavaScript. In: Proceedings of OOPSLA 2013, pp. 729–744. ACM (2013)Google Scholar
  15. 15.
    Honda, K., Yoshida, N., Carbone, M.: Multiparty asynchronous session types. ACM SIGPLAN Notices 43(1), 273–284 (2008). (Proceedings of POPL 2008)CrossRefzbMATHGoogle Scholar
  16. 16.
    Jongmans, S.-S.T.Q.: Automata-theoretic protocol programming. Ph.D. thesis, Leiden University (2016)Google Scholar
  17. 17.
    Jongmans, S.-S.T.Q., Arbab, F.: PrDK: protocol programming with automata. In: Chechik, M., Raskin, J.-F. (eds.) TACAS 2016. LNCS, vol. 9636, pp. 547–552. Springer, Heidelberg (2016). doi: 10.1007/978-3-662-49674-9_33 CrossRefGoogle Scholar
  18. 18.
    Jongmans, S.-S.T.Q., Arbab, F.: Overview of thirty semantic formalisms for Reo. Sci. Ann. Comput. Sci. 22(1), 201–251 (2012)MathSciNetGoogle Scholar
  19. 19.
    Jongmans, S.-S.T.Q., Arbab, F.: Can high throughput atone for high latency in compiler-generated protocol code? In: Dastani, M., Sirjani, M. (eds.) FSEN 2015. LNCS, vol. 9392, pp. 238–258. Springer, Cham (2015). doi: 10.1007/978-3-319-24644-4_17 CrossRefGoogle Scholar
  20. 20.
    Krauweel, M.: Concurrent and asynchronous JavaScript programming using Reo. Master’s thesis, Open University of the Netherlands (2017)Google Scholar
  21. 21.
    Myter, F., Scholliers, C., De Meuter, W.: Many spiders make a better web: a unified web-based actor framework. In: Proceedings of AGERE 2016, pp. 51–60. ACM (2016)Google Scholar
  22. 22.
    Ng, N., Yoshida, N.: Pabble: parameterised Scribble. Service Oriented Comput. Appl. 9(3-4), 269–284 (2015)Google Scholar
  23. 23.
    Parnas, D.: On the criteria to be used in decomposing systems into modules. Commun. ACM 15(12), 1053–1058 (1972)CrossRefGoogle Scholar
  24. 24.
    Philips, L., De Koster, J., De Meuter, W., De Roover, C.: Dependence-driven delimited CPS transformation for JavaScript. In: Proceedings of GPCE 2016, pp. 59–69. ACM (2016)Google Scholar
  25. 25.
    Radoi, C., Herhut, S., Sreeram, J., Dig, D.: Are web applications ready for parallelism? In: Proceedings of PPoPP 2015. ACM (2015)Google Scholar
  26. 26.
    Stivan, G., Peruffo, A., Haller, P.: Akka. js: towards a portable actor runtime environment. In: Proceedings of AGERE! 2015, pp. 57–64. ACM (2015)Google Scholar
  27. 27.
    Welc, A., Hudson, R., Shpeisman, T., Adl-Tabatabai, A.R.: Generic workers: towards unified distributed and parallel Javascript programming model. In: Proceedings of PSI EtA 2010. ACM (2010)Google Scholar
  28. 28.
    Zakas, N.: Promises and Asynchronous Programming. In: Understanding ECMAScript 6, Chap. 11, 1st edn., pp. 213–241. No Starch Press (2016)Google Scholar

Copyright information

© IFIP International Federation for Information Processing 2017

Authors and Affiliations

  1. 1.Department of Computer ScienceOpen University of the NetherlandsHeerlenThe Netherlands
  2. 2.Department of ComputingImperial College LondonLondonUK

Personalised recommendations