A concurrency model for JavaScript with cooperative cancellation

Tian Zhao, Yonglun Li
{"title":"A concurrency model for JavaScript with cooperative cancellation","authors":"Tian Zhao, Yonglun Li","doi":"10.1145/3486608.3486911","DOIUrl":null,"url":null,"abstract":"This paper proposes a concurrency model for JavaScript with thread-like abstractions and cooperative cancellation. JavaScript uses an event-driven model, where an active computation runs until it completes or blocks for an event while concurrent computations wait for other events as callbacks. With the introduction of Promises, the control flow of callbacks can be written in a more direct style. However, the event-based model is still a source of confusion with regard to execution order, race conditions, and termination. The thread model is a familiar concept to programmers and can help reduce concurrency errors in JavaScript programs. This work is a library-based design, which uses an abstraction based on the reader monad to pass a thread ID through a thread's computation. A thread can be cancelled, paused, and resumed with its thread ID. This design allows hierarchical cancellation where a child thread is cancelled if its parent is cancelled. It also defines synchronization primitives to protect shared states. A formal semantics is included to give a precise definition of the proposed model.","PeriodicalId":212947,"journal":{"name":"Proceedings of the 14th ACM SIGPLAN International Conference on Software Language Engineering","volume":"38 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2021-10-17","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"1","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Proceedings of the 14th ACM SIGPLAN International Conference on Software Language Engineering","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.1145/3486608.3486911","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 1

Abstract

This paper proposes a concurrency model for JavaScript with thread-like abstractions and cooperative cancellation. JavaScript uses an event-driven model, where an active computation runs until it completes or blocks for an event while concurrent computations wait for other events as callbacks. With the introduction of Promises, the control flow of callbacks can be written in a more direct style. However, the event-based model is still a source of confusion with regard to execution order, race conditions, and termination. The thread model is a familiar concept to programmers and can help reduce concurrency errors in JavaScript programs. This work is a library-based design, which uses an abstraction based on the reader monad to pass a thread ID through a thread's computation. A thread can be cancelled, paused, and resumed with its thread ID. This design allows hierarchical cancellation where a child thread is cancelled if its parent is cancelled. It also defines synchronization primitives to protect shared states. A formal semantics is included to give a precise definition of the proposed model.
查看原文
分享 分享
微信好友 朋友圈 QQ好友 复制链接
本刊更多论文
具有协作取消的JavaScript并发模型
本文提出了一种基于线程抽象和协同取消的JavaScript并发模型。JavaScript使用事件驱动模型,其中活动计算运行直到它完成或阻塞事件,而并发计算等待其他事件作为回调。通过引入Promises,回调的控制流可以用更直接的风格编写。然而,基于事件的模型在执行顺序、竞争条件和终止方面仍然容易引起混淆。线程模型是程序员熟悉的概念,可以帮助减少JavaScript程序中的并发错误。这项工作是基于库的设计,它使用基于reader单子的抽象来通过线程的计算传递线程ID。可以使用线程ID取消、暂停和恢复线程。这种设计允许分层取消,如果父线程被取消,子线程也会被取消。它还定义了同步原语来保护共享状态。其中包括一个形式语义,以给出所建议模型的精确定义。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 去求助
相关文献
Proposing a new loan recommendation framework for loan allocation strategies in online P2P lending
IF 0 Ind. Manag. Data Syst.Pub Date : 2023-01-26 DOI: 10.1108/imds-07-2022-0399
Yuting Rong, Shangjie Liu, Shuo Yan, Wei Huang, Yanxia Chen
Improving building resilience in the face of future climate uncertainty: A comprehensive framework for enhancing building life cycle performance
IF 6.7 2区 工程技术Energy and BuildingsPub Date : 2023-11-19 DOI: 10.1016/j.enbuild.2023.113761
Ruijun Chen , Holly Samuelson , Yukai Zou , Xianghan Zheng , Yifan Cao
来源期刊
自引率
0.00%
发文量
0
期刊最新文献
Proceedings of the 14th ACM SIGPLAN International Conference on Software Language Engineering Fast incremental PEG parsing New ideas: automated engineering of metamorphic testing environments for domain-specific languages Vision: the next 700 language workbenches Getting grammars into shape for block-based editors
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
现在去查看 取消
×
提示
确定
0
微信
客服QQ
Book学术公众号 扫码关注我们
反馈
×
意见反馈
请填写您的意见或建议
请填写您的手机或邮箱
已复制链接
已复制链接
快去分享给好友吧!
我知道了
×
扫码分享
扫码分享
Book学术官方微信
Book学术文献互助
Book学术文献互助群
群 号:481959085
Book学术
文献互助 智能选刊 最新文献 互助须知 联系我们:info@booksci.cn
Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。
Copyright © 2023 Book学术 All rights reserved.
ghs 京公网安备 11010802042870号 京ICP备2023020795号-1