【正文】
y marked as such by use of the virtual modi?er, while methods that are intended to override ones inherited from a superclass must explicitly say so with the override modi?er. code such as class C { virtual void f () amp。 (buff . Get() + buff . Get())。 Philippsen 1995], only monitors have gained widespread acceptance as programming constructs. An interesting new linguistic approach has emerged recently with Four and Gonthier?s [1996, 2020] join calculus, a process calculus well suited to direct implementation in a distributed setting. Other languages, such as JoCaml [Conchon and Le Fessant 1999] and Funnel [Odersky 2020], bine similar ideas with the functional programming model. Here we propose an adapta tion of join calculus ideas to an object oriented language that has an existing thread sand locks concurrency model. Itzstein and Kearney [2020] have recently described very similar extensions for Java. Asynchronous Programming Asynchronous events and message passing are increasingly used at all levels of software systems. At the lowest level, device drivers have to respond promptly to asynchronous device events, while being parsimonious on resource use. At the Graphical User Interface level, code and programming models are notoriously plex because of the asynchronous nature of user events。 附件 2:外文原文 Modern Concurrency Abstractions for C NICK BENTON, LUCA CARDELLI, and CEDRIC FOURNET Microsoft Research 1. INTRODUCTION Languages and Concurrency Concurrency is an important factor in the behaviour and performance of modern code: concurrent programs are dif?cult to design, write, reason about, debug, and tune. Concurrency can signi?cantly affect the meaning of virtually every other construct in the language (beginning with the atomicity of assignment), and can affect the ability to invoke libraries. Despite this, most popular pro gramming languages treat concurrency not as a language feature, but as a collection of external libraries that are often underspeci?ed. Considerable attention has been given, after the fact, to the speci?cation of important concurrency libraries [Birrell et al. 1987。 Join2 x = new Join2()。 public Join2() { ?rstcb = new IntCallback(?rst)。 } void wait() amp。例如,上面的代碼,編寫者未必能夠獲得新的讀者只要獨(dú)占鎖獲得一個共享鎖。 s()。在上面的例子中, n 是有關(guān)的,只有當(dāng)有消息中的()。 async s(int n) {s(n + 1)。每個客戶的要求,然后釋放,要么共享訪問或獨(dú)占訪問,使用相應(yīng)的共享的公共方法,釋放共享,獨(dú)家,釋放獨(dú)占。 獲取和弦。 } public object Get() amp。 4。 return ()。 } } 將匹配的雙 F 和 G 的調(diào)用,然后交換它們的值并繼續(xù)。在該文件中,類(部分)同步的集合可以使用一些繼承運(yùn)營商結(jié)合和轉(zhuǎn)化的模式。 更務(wù)實(shí)的態(tài)度,消除對繼承的限制,使得這一切太容易引入無意僵局(或“異步泄漏”)。 這些條件大多是相當(dāng)簡單的,但條件 2 和 9 值得我們進(jìn)一步的評論。 在一個單一的復(fù)調(diào)聲明: ( 2)最多的一種方法頭可能有非異步的返回類型。如果有排隊(duì)調(diào)用 Put()s,那么哪一個同步隨后 Get()是不確定的。緩沖區(qū)的例子定義了兩個方法使用一個單一的復(fù)調(diào)。答案是,在任何給定的弦,最多的一種方法可能是同步的。 如果沒有掛起調(diào)用的 (),然后調(diào)用到 buff . Put(s)僅僅是排隊(duì),直到一個個到達(dá)。 public async Put(string s) { return s。由于異步方法立即返回,方法的調(diào)用如下 : async postEvent(EventInfo data) { // large method body } 是唯一可以合理地調(diào)用立即返回,“大被安排在不同的線程執(zhí)行方法體“(無論是一個新的催生了以服務(wù)這個呼叫,或者從一些游泳池的工人)。復(fù)調(diào) C#語言概述 本節(jié)介紹新構(gòu)造復(fù)調(diào)的 C#語法和語義,然后給出了更精確,雖然仍是非正式的,規(guī)范 語法。 .NET 執(zhí)行引擎提供了一個多線程的執(zhí)行環(huán)境潛在的相互關(guān)聯(lián)與同步鎖MENT 在堆上分配的對象。然而,如果我們能有些隱藏在背后的消息和線程使用一種語言機(jī)制,那么很多的選項(xiàng)成為可能。 itzstein 和 Kearney [2020]最近為 Java 描述非常類似的擴(kuò)展。盡管出現(xiàn)大規(guī)模的模式設(shè)計(jì)如 [America 1989。 我們相信,并發(fā)應(yīng)該是一個語言功能的一部分和一種語言規(guī)范。 2020] 已給予相當(dāng)?shù)闹匾?,通常通過這些規(guī)范就可以對他們的行為應(yīng)該在何處執(zhí)行做出判斷??ù鳡柡腿吕锟?富爾 微軟研究院 語言和并發(fā) 并發(fā)是現(xiàn)代代碼中的一個重要實(shí)現(xiàn)形式:并發(fā)程序的編寫設(shè)計(jì),解釋,調(diào)試,和調(diào)整都是有難度的??紤]到這樣的事實(shí)后,規(guī)范的并發(fā)庫 [比勒爾等。有“語言”等功能的優(yōu)點(diǎn)是,編輯者可以對它們進(jìn)行分析,因此可以產(chǎn)生更好的代碼,并警告親程序員的潛在和實(shí)際問題。 許多事情因 為監(jiān)控器被引入并發(fā)而已經(jīng)改變。 Pierce and Turner 2020。在圖形用戶界面級別是出了名的,復(fù)雜的代碼和編程模型,因?yàn)橛脩羰录漠惒叫再|(zhì) 。因此,我們的目標(biāo)是促進(jìn)異步編程抽象是高層次的,從一個程序員的角度來看,使低層次的優(yōu)化,從一個編譯器和運(yùn)行時(shí)系統(tǒng)的角度來看。 .NET 框架還提供更高級別的基礎(chǔ)設(shè)施建設(shè)分布應(yīng)用和服務(wù),如基于 SOAP 的消息傳遞和遠(yuǎn)程方法打電話。傳統(tǒng)的方法是同步的,在檢測到來電者沒有取得任何進(jìn)展,直到被叫方完成。復(fù)調(diào)。 async Put(string s)方法是異步的(沒有返回結(jié)果),并接受一個字符 串參數(shù)。 buff . Put(“sky”)。還應(yīng)當(dāng)指出,緩沖區(qū)的代碼,瑣碎,但它是,是線程安全的。 public async Put(string s) { return s。我們添加一個新的關(guān)鍵字 async,并添加它作為一種替代的返回類型: returntype : := type | void | async 這使得方法,代表和接口方法被宣布異步的。 ( 5)兩種方法,頭可能沒有相同 的成員名稱和相同的參數(shù)類型簽名。這里是我們的方法來執(zhí)行這兩個關(guān)注點(diǎn)分離:一系列的復(fù)調(diào),必須是當(dāng)?shù)氐囊活惢蜃宇惵暶鞯恼Z法 。 private async g () { /? body1 ?/ } 是不正確的聲明只是一個 F()和 g()是虛擬的,是沒有意義的(是作為我們的編譯器的錯誤標(biāo)記),作為壓倒一切的要求其他要重寫了。格式良好上述條件 2也是合理的,由現(xiàn)有的 C功能和純加入演算之間的潛在的不良相互作用。但是,在C,選擇線程做一個方案由于到折返鎖,基于堆棧的安全性和線程局部變量,從而使行為的顯著性差異“非常”非交換。 // returning to f 8 return i。單元格有兩種公共同步方法: void Put(object o) 和 object Get()。 } } 在另外兩個公共方法,類使用兩個私人異步方法, empty()和 contains(object o),進(jìn)行單元格的狀態(tài)。在所有其他情況下,提出并獲取等待。和弦 199。 else s(n ? 1)。 // protected by s() public void Shared() amp。 else s()。 async t() { if (??n == 0) idleExclusive()。 public class Service { public async Request(string arg, IntCallback cb) { int r 。 async ?rst(int fst) amp。 ... int i, j 。 Gurevich et al. 2020] to the point where one can usually determine what their behaviour should be under any Implementation. Yet, even when the concurrency libraries are satisfactorily speci?ed, the simple fact that they are libraries, and not features of the language, has undesirable consequences. Many features can be provided, in principle, either as language features or as libraries: typical examples are memory management and exceptions. The advantage of having such features “in the language” is that the piler can analyze them, and can therefore produce better code and warn programmers of potential and actual problems. In particular, the piler can check for syntactically embedded invariants that would be dif?cult to extract from a collection of library calls. Moreover, programmers can more reliably state their intentions through a clear syntax, and tools other than the piler can more easily determine the programmers? intentions. Domain Speci?c Languages [Ramming 1997。?. The body is only executed once all the methods in the header have been called. Method calls are implicitly queued up until/unless there is a matching chord. Consider for example public class Buffer { public string Get() amp。 public async Put(string s) { retu