JS_YieldRequest

  • Revision slug: SpiderMonkey/JSAPI_Reference/JS_YieldRequest
  • Revision title: JS_YieldRequest
  • Revision id: 146631
  • Created:
  • Creator: Jorend
  • Is current revision? No
  • Comment doc change in bug 412985, etc.

Revision Content

{{template.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. {{wiki.template('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, except for {{template.Bug(402898)}} (JS_YieldRequest does not cause cx to relinquish objects it's holding to other threads that are blocked waiting for them).

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

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

Revision Source

<p>{{template.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.
{{wiki.template('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>, except for {{template.Bug(402898)}} (<code>JS_YieldRequest</code> does not cause <code>cx</code> to relinquish objects it's holding to other threads that are blocked waiting for them).
</p><p>{{template.Jsapi_maxversion_inline(1.8)}} <code>JS_YieldRequest</code> is available only in <code><a href="en/JS_THREADSAFE">JS_THREADSAFE</a></code> builds.  In JSAPI 1.9 and later, this function will be present, but will do nothing, in non-<code>JS_THREADSAFE</code> builds.
</p><p>{{template.LXRSearch("ident", "i", "JS_YieldRequest")}}
</p>
Revert to this revision