<p>Synchronization variables (also often called dataflow variables in the literature) are variables that can be written only once; attempts to read the variable block until it has been written to.</p>
<p>Synchronization variables are created with <code class="func">CreateSyncVar</code> (<a href="chap9_mj.html#X7B55EA0E8672087C"><span class="RefLink">9.1-1</span></a>), written with <codeclass="func">SyncWrite</code> (<a href="chap9_mj.html#X85E910BF7BBF3270"><span class="RefLink">9.1-2</span></a>) and read with <code class="func">SyncRead</code> (<a href="chap9_mj.html#X7B42B29B8441B4F5"><span class="RefLink">9.1-3</span></a>).</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ CreateSyncVar</code>( )</td><td class="tdright">( function )</td></tr></table></div>
<p>The function <code class="func">CreateSyncVar</code> takes no arguments. It returns a new synchronization variable. There is no need to deallocate it; the garbage collector will free the memory and all related resources when it is no longer accessible.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ SyncWrite</code>( <var class="Arg">syncvar</var>, <var class="Arg">obj</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="func">SyncWrite</code> attempts to assign the value <var class="Arg">obj</var> to <var class="Arg">syncvar</var>. If <var class="Arg">syncvar</var> has been previously assigned a value, the call will fail with a runtime error; otherwise, <var class="Arg">obj</var> will be assigned to <var class="Arg">syncvar</var>.</p>
<p>In order to make sure that the recipient can read the result, the <var class="Arg">obj</var> argument should not be a thread-local object; it should be public, read-only, or shared.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ SyncRead</code>( <var class="Arg">syncvar</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="func">SyncRead</code> reads the value previously assigned to <var class="Arg">syncvar</var> with <code class="func">SyncWrite</code> (<a href="chap9_mj.html#X85E910BF7BBF3270"><span class="RefLink">9.1-2</span></a>). If no value has been assigned yet, it blocks. It returns the assigned value.</p>
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Die farbliche Syntaxdarstellung ist noch experimentell.
Die farbliche Syntaxdarstellung ist noch experimentell.