JS_YieldRequest

  • Revision slug: SpiderMonkey/JSAPI_Reference/JS_YieldRequest
  • Revision title: JS_YieldRequest
  • Revision id: 146633
  • Created:
  • Creator: Jorend
  • Is current revision? No
  • Comment /* Description */ fix version numbers

Revision Content

{{ Jsapi_ref_header("JS_YieldRequest") }}

Momentarily suspend the current JSAPI request, allowing garbage collection to run if another thread has requested it.

Syntax

void JS_YieldRequest(JSContext *cx);
Name Type Description
cx JSContext * The JSContext that is currently in a request on the calling thread. {{ Jsapi-requires-request() }}

Description

For more information about thread safety and requests, see JS_THREADSAFE.

JS_YieldRequest momentarily suspends the current request. A program can call this function periodically to ensure that a long-running request does not block garbage collection indefinitely. The effect is the same as a call to JS_SuspendRequest immediately followed by a call to JS_ResumeRequest.

{{ Jsapi_maxversion_inline("1") }} JS_YieldRequest did not cause cx to relinquish objects it created to other threads that are blocked waiting for them. This bug ({{ Bug("402898") }}) will be fixed in SpiderMonkey 1.8.

{{ Jsapi_maxversion_inline("1") }} JS_YieldRequest is available only in JS_THREADSAFE builds. In SpiderMonkey 1.8 and later, this function will be present, but will do nothing, in non-JS_THREADSAFE builds.

{{ LXRSearch("ident", "i", "JS_YieldRequest") }}

Revision Source

<p>{{ Jsapi_ref_header("JS_YieldRequest") }}
</p><p>Momentarily suspend the current JSAPI request, allowing garbage collection to run if another thread has requested it.
</p>
<h2 name="Syntax"> Syntax </h2>
<pre class="eval">void <b>JS_YieldRequest</b>(<a href="en/JSContext">JSContext</a> *cx);
</pre>
<table class="fullwidth-table">
<tbody><tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td><code>cx</code></td>
<td><code><a href="en/JSContext">JSContext</a> *</code></td>
<td>The <code>JSContext</code> that is currently in a request on the calling thread.
{{ Jsapi-requires-request() }}</td>
</tr>
</tbody></table>
<h2 name="Description"> Description </h2>
<dl><dd><i>For more information about thread safety and requests, see <code><a href="en/JS_THREADSAFE">JS_THREADSAFE</a></code>.</i>
</dd></dl>
<p><code>JS_YieldRequest</code> momentarily suspends the current request. A program can call this function periodically to ensure that a long-running request does not block garbage collection indefinitely. The effect is the same as a call to <code><a href="en/JS_SuspendRequest">JS_SuspendRequest</a></code> immediately followed by a call to <code><a href="en/JS_ResumeRequest">JS_ResumeRequest</a></code>.
</p><p>{{ Jsapi_maxversion_inline("1") }} <code>JS_YieldRequest</code> did not cause <code>cx</code> to relinquish objects it created to other threads that are blocked waiting for them. This bug ({{ Bug("402898") }}) will be fixed in SpiderMonkey 1.8.
</p><p>{{ Jsapi_maxversion_inline("1") }} <code>JS_YieldRequest</code> is available only in <code><a href="en/JS_THREADSAFE">JS_THREADSAFE</a></code> builds. In SpiderMonkey 1.8 and later, this function will be present, but will do nothing, in non-<code>JS_THREADSAFE</code> builds.
</p><p>{{ LXRSearch("ident", "i", "JS_YieldRequest") }}
</p>
Revert to this revision