old-code/monodoc/ecma334/10.10.xml

5 строки
1.7 KiB
XML

<?xml version="1.0"?>
<clause number="10.10" title="Execution order">
<paragraph>Execution shall proceed such that the side effects of each executing thread are preserved at critical execution points. A side effect is defined as a read or write of a volatile field, a write to a non-volatile variable, a write to an external resource, and the throwing of an exception. The critical execution points at which the order of these side effects must be preserved are references to volatile fields (<hyperlink>17.4.3</hyperlink>), lock statements (<hyperlink>15.12</hyperlink>), and thread creation and termination. An implementation is free to change the order of execution of a C# program, subject to the following constraints: <list><list_item> Data dependence is preserved within a thread of execution. That is, the value of each variable is computed as if all statements in the thread were executed in original program order. </list_item><list_item> Initialization ordering rules are preserved (<hyperlink>17.4.4</hyperlink> and <hyperlink>17.4.5</hyperlink>). </list_item><list_item> The ordering of side effects is preserved with respect to volatile reads and writes (<hyperlink>17.4.3</hyperlink>). Additionally, an implementation need not evaluate part of an expression if it can deduce that that expression's value is not used and that no needed side effects are produced (including any caused by calling a method or accessing a volatile field). When program execution is interrupted by an asynchronous event (such as an exception thrown by another thread), it is not guaranteed that the observable side effects are visible in the original program order. </list_item></list></paragraph>
</clause>