【正文】
methodheader]? body Methodheader : := attributes modi?ers returntype membername(formals). We call a chord declaration trivial if it declares a single, synchronous method (. it is a standard C method declaration). WellFormedness Extended classes are subject to a number of well formedness conditions: — Within a single methodheader: (1) If returntype is async then the formal parameter list formals may not contain any ref or out parameter — Within a single chorddeclaration: (2) At most one methodheader may have a nonasync returntype. (3) If the chord has a methodheader with returntype type, then body may use return statements with type expressions, otherwise body may use empty return statements. (4) All the formals appearing in methodheaders must have distinct identi?ers. (5) Two methodheaders may not have both the same member name and the same argument type signature. (6) The methodheaders must either all declare instance methods or all declare static methods. — Within a particular class: (7) All methodheaders with the same membername and argument type signature must have the same returntype and identical sets of attributes and modi?ers. (8) If it is a value class (struct), then only static methods may appear in nontrivial chords. (9) If any chorddeclaration includes a virtual method m with the override modi?er,5 then any method n that appears in a chord with m in the super class containing the overridden de?nition of m must also be overridden in the subclass. Most of these conditions are fairly straightforward, though Conditions 2 and 9 deserve some further ment. Condition 9 provides a conservative, but simple, sanity check when re?ning a 16 class that contains chords since, in general, implementation inheritance and concurrency do not mix well [Matsuoka and Yonezawa 1993] (see Four et al. [2020] for a discussion of “inheritance anomalies” in the context of the join calculus). Our approach here is to enforce a separation of these two concerns: a series of chords must be syntactically local to a class or a subclass declaration。 buff . Put(“sky”)。 Pierce and Turner 2020。概括注冊(當(dāng)然,自然屬于通用庫)任意同時通 話,或定義類的條件,如等待至少 35 通話已完成很簡單的。 Service s2 = . . . 。 public IntCallback secondcb。 wait()。因此,它是非常有用的一些明確具體公平或優(yōu)先的額外的應(yīng)用程序編程。 async s() { n++。萬一有一個消息,等候在一個給定的私有方法,它是一個選擇的問題,是否使用私有字段的對象或參數(shù)在私人訊息。 } public void Shared() amp。),因此也可以作為直接讀取類定義一個自動的規(guī)范: 9 讀寫鎖 作為一個異步方法的使用進(jìn)行狀態(tài)更現(xiàn)實的例子和同步訪問該狀態(tài)的和弦,我們現(xiàn)在考慮的經(jīng)典問題多的讀者,作家單鎖保護(hù)共享的易變的資源。如果我們把一個單元格是一個空的()對象,然后單元格隨后包含( O)。 private async empty() { contains(o)。這種設(shè)計使得直觀的感覺(異步方法無效,但有額外的屬性返回“立即”),并最大限度地使用現(xiàn)有的 C代碼(父類,接口和兼容性委托的定義)的無效使用。 af (i, t)。 return i to g 。 [2020]為更深入的研究在繼承和并發(fā)加入演算。 virtual async h() { /? body2 ?/ } } } class D : C { override async g () { /? body3 ?/ } 一個會覆蓋 G(),也有“一半”重寫 F()。 ( 9)如果任何復(fù)調(diào)聲明包括一個覆蓋虛擬方法 M 修飾符,那么任何方法 n 出現(xiàn)在包含重寫定義的 m 的超弦與 M 也必須被重寫在子類中。 良好的格式 擴(kuò)展類是格式良好的條件: 在一個單一的方法頭: ( 1)如果返回類型是異步的,那么正式的參數(shù)列表中的形參不得 包含任何 ref 或 out 參數(shù)修飾符。 Get()調(diào)用可以同步調(diào)用的 put()方法。任何相互排斥的需要,必須明確在編程在弦頭的同步條件。讀者在這一點上可能會想什么規(guī)則決定在哪個線程體運行,或如何,我們知道,方法調(diào)用將返回人體所計算的最終價值。 相反,在調(diào)用異步方法的 buff . Put(.),來電從未等待,但 對于其他線程可能有兩種行為: 如果有以前的未匹配過的通話 buff . Get()再有就是現(xiàn)在的一次匹配,所以掛起調(diào)用出列和其相關(guān)阻塞的線程是喚醒運行的復(fù)調(diào),返回值給 s??紤],例如 : public class Buffer { public string Get() amp。調(diào)用異步方法很像是發(fā)送消息,或張貼的 事件。 2。 C#程序上運行 .NET 框架,其中包括多語言的執(zhí)行頂部 引擎和一個豐富的類庫集合。主題仍 然是一個在大多數(shù)系統(tǒng)中昂貴的資源。在這里,我們提出了一個加入演算想法的適應(yīng)一個面向?qū)ο蟮恼Z言,有一個現(xiàn)有線程和鎖的并發(fā)模型。 這些新的要求應(yīng)該得到可以處理異步通信和不束縛共享記憶的編程結(jié)構(gòu)的方法。 Kamin 1997]是一 個極端的語言學(xué)方法的例子:經(jīng)常提出新的特設(shè)語言并不是要取代通用的語言,而是為了方便特定于域的代碼分析域相關(guān)的功能,作為原始的語言表達(dá)簡單的事實結(jié)構(gòu)。 1998年古列維奇等。本頓,盧卡 1987 年 。特別是,編譯器可以檢查語法嵌入的變量,這將是很難從庫中提取調(diào)用的集合。通信已變得更加的異步,并行計算一定要通過規(guī)模較大的“精心策劃”的。 Philippsen 1995],但只有監(jiān)控器獲得廣泛接受的編程結(jié)構(gòu)。在同一時間,用戶討厭被不必要的封鎖。我們提出用現(xiàn)代并發(fā) C#語言的 延伸異步編程抽象。 .NET Framework 中的并發(fā)和分配機(jī)制功能強(qiáng)大,但他們也不可否認(rèn)復(fù)雜。復(fù)調(diào) C#中,如果一個方法被聲明為異步調(diào)用任何保證立即基本上完成。復(fù)調(diào)(也被稱為“同步模 5 式”,或“加盟模式”)由一個頭和一個身體。如果 buff 是緩沖和一個調(diào)用同步方法的 ]的一個 buff . Get()實例。 (buff . Get() + buff . Get())。需要鎖定(例如,以防止參數(shù)返回兩個不同的獲取到一個單放)自動生成由編譯器。 } public string Get() amp。在類成員的聲明中,我們更換方法聲明 chorddeclaration : := methodheader [amp。 ( 6)的方法,頭必須全部申報的實例方法或所有聲明的靜態(tài)方法。方法重寫時,他們所有的復(fù)調(diào)還必須完全重寫。這也是值得觀察,有一個傳遞閉包操作隱含在我們繼承的限制:如果 f()是重寫,并加入與 g(),然后因為 g()必須被覆蓋,所以必須任何方法 H()加入與 g()等。允許多個同步調(diào)用出現(xiàn)在一個單一的復(fù)調(diào)會給一種潛在的有用的交會設(shè)施(提供一個也加入語法允許特定的調(diào)用返回結(jié)果)。 當(dāng)然,這也不是 很難明確方案復(fù)調(diào) C上述交會: class RendezVous { class Thunk { int wait() amp。 // returning to g } } 對于每個調(diào)用到 f,我們創(chuàng)建了一個輔助類咚的實例,為了等待異步答復(fù)消息,這是同步后發(fā)送一些 ?。把呼叫塊,直到單元格是空的,然后用它的參數(shù)填充單元。有一個簡單的聲明構(gòu)造和解釋兩個和弦這是如何工作: 構(gòu)造。 使用私人異步方法(而不是域)的技術(shù)攜帶狀態(tài)是很常見的和弦的 C#。#,它可以只有五 和弦: class ReaderWriter { } ReaderWriter() {idle()。 } public void Exclusive() amp。 async idle() { n = 1。 } public void Exclusive() amp。 else t()。 . . . // do some work cb(r)。 async second(int snd) { i = fst。 (out i, out j )。 Kamin 1997] are an extreme example of this linguistic approach: new adhoc languages are routinely proposed not to replace general purpose language, but to facilitate domain speci?c code analysis by the simple fact of expressing domain related features as primitive language constructs. We believe that concurrency should be a language feature and a part of language speci?cations. Serious attempts in this direction were made beginning in the 1970s with the concept of monitors [Hoare 1974] and the Occam language [INMOS Limited 1984] (based on Communicating Sequential Processes [Hoare 1985]). The general notion of monitors has bee very popular, particularly in its current object oriented form of threads and object bound mutexes, but it has been provided at most as a veneer of syntactic sugar for optionally locking objects on method calls. Many things have changed in concurrency since monitors were introduced. Communication has bee more asynchronous, and concurrent putations have to be “orchestrated” on a larger scale. The concern is not as much with the ef?cient implementation 12 and use of