JS_YieldRequest

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

Revision Content

{{template.Jsapiref()}}

Momentarily suspend the current JSAPI request, allowing garbage collection to run if needed and allowing objects to be used by other threads.

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

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).

Notes

JS_YieldRequest is available only if you compile the JS engine with JS_THREADSAFE defined. In a default engine compilation, JS_THREADSAFE is undefined.

See Also

Groups Functions
Documents {{template.LXRSearch("ident", "i", "JS_YieldRequest", "LXR ID Search")}}
Entries

JS_BeginRequest, JS_EndRequest, JS_SuspendRequest, JS_ResumeRequest

Revision Source

<p> 
{{template.Jsapiref()}}
</p><p>Momentarily suspend the current JSAPI request, allowing garbage collection to run if needed and allowing objects to be used by other threads.
</p>
<h2 name="Syntax"> Syntax </h2>
<pre class="eval">void <b>JS_YieldRequest</b>(JSContext *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>JSContext *</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>
<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>
<h3 name="Notes"> Notes </h3>
<p><code>JS_YieldRequest</code> is available only if you compile the JS engine with <code><a href="en/JS_THREADSAFE">JS_THREADSAFE</a></code> defined. In a default engine compilation, <code>JS_THREADSAFE</code> is undefined.
</p>
<h2 name="See_Also"> See Also </h2>
<table class="fullwidth-table">
<tbody><tr>
<td>Groups</td>
<td><a href="en/JSAPI_Reference#Functions">Functions</a></td>
</tr>
<tr>
<td>Documents</td>
<td>{{template.LXRSearch("ident", "i", "JS_YieldRequest", "LXR ID Search")}}</td>
</tr>
<tr>
<td>Entries</td>
<td>
<p><a href="en/JS_BeginRequest">JS_BeginRequest</a>,
<a href="en/JS_EndRequest">JS_EndRequest</a>,
<a href="en/JS_SuspendRequest">JS_SuspendRequest</a>,
<a href="en/JS_ResumeRequest">JS_ResumeRequest</a>
</p>
</td>
</tr>
</tbody></table>
Revert to this revision