JavaScript-1.5 Reference

JS_SuspendRequest Function

Summary

Indicates to the JS engine that an application thread executing JS API calls in a request can suspend its API-calling critical section and block.

Syntax

jsrefcount JS_SuspendRequest(JSContext *cx);

Description

When your multi-threaded application is in a request but needs to block or perform lengthy computation that can race safely with the garbage collector, it should call JS_SuspendRequest before the blocking or lengthy call, and JS_ResumeRequest after. JS_SuspendRequest safely decrements the request counter for the JS engine runtime associated with a given context, cx. JS_SuspendRequest returns the saved value of the request-depth counter stored in cx, which must be passed to the matching JS_SuspendRequest after the blocking or lengthy code completes.

Notes

JS_SuspendRequest 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 [ Function ]
Documents [ LXR ID Search ]
Entries [ JS_BeginRequest | JS_EndRequest | JS_ResumeRequest ]

This page was generated by APIDOC