mozilla

Revision 195197 of PR_AtomicSet

  • Revision slug: PR_AtomicSet
  • Revision title: PR_AtomicSet
  • Revision id: 195197
  • Created:
  • Creator: Rappo
  • Is current revision? Yes
  • Comment

Revision Content

{{ Nsprapiref("Atomic Operations") }}

Atomically sets a 32-bit value and return its previous contents.

Syntax

#include <pratom.h> 

PRInt32 PR_AtomicSet(
  PRInt32 *val,
  PRInt32 newval);

Parameter

The function has the following parameter:

val
A pointer to the value to be set.
newval
The new value to assign to the val parameter.

Returns

The function returns the prior value of the referenced variable.

Description

PR_AtomicSet first reads the value of var, then updates it with the supplied value. The returned value is the value that was read before memory was updated. The memory modification is unconditional--that is, it isn't a test and set operation.

Revision Source

<p>
{{ Nsprapiref("Atomic Operations") }}
</p><p>Atomically sets a 32-bit value and return its previous contents.
</p>
<h3 id="Syntax" name="Syntax"> Syntax </h3>
<pre class="eval">#include &lt;pratom.h&gt; 

<a href="en/PRInt32">PRInt32</a> PR_AtomicSet(
  PRInt32 *val,
  PRInt32 newval);
</pre>
<h3 id="Parameter" name="Parameter"> Parameter </h3>
<p>The function has the following parameter:
</p>
<dl><dt><code>val</code>
</dt><dd>A pointer to the value to be set.
</dd><dt><code>newval</code>
</dt><dd>The new value to assign to the <code>val</code> parameter.
</dd></dl>
<h3 id="Returns" name="Returns"> Returns </h3>
<p>The function returns the prior value of the referenced variable.
</p>
<h3 id="Description" name="Description"> Description </h3>
<p><code>PR_AtomicSet</code> first reads the value of var, then updates it with the supplied value. The returned value is the value that was read <i>before</i> memory was updated. The memory modification is unconditional--that is, it isn't a test and set operation.
</p>
Revert to this revision