MCPcopy Create free account
hub / github.com/Distributive-Network/PythonMonkey / JobQueue

Class JobQueue

include/JobQueue.hh:24–150  ·  view source on GitHub ↗

* @brief Implement the ECMAScript Job Queue: * https://www.ecma-international.org/ecma-262/9.0/index.html#sec-jobs-and-job-queues * @see https://hg.mozilla.org/releases/mozilla-esr102/file/5741ffa/js/public/Promise.h#l22 */

Source from the content-addressed store, hash-verified

22 * @see https://hg.mozilla.org/releases/mozilla-esr102/file/5741ffa/js/public/Promise.h#l22
23 */
24class JobQueue : public JS::JobQueue {
25
26public:
27explicit JobQueue(JSContext *cx);
28~JobQueue() = default;
29
30/**
31 * @brief Initialize PythonMonkey's event-loop job queue
32 * @param cx - javascript context pointer
33 * @return success
34 */
35bool init(JSContext *cx);
36
37/**
38 * @brief Ask the embedding for the host defined data.
39 *
40 * SpiderMonkey doesn't itself have a notion of host defined data as defined
41 * by the HTML spec, so we need the embedding to provide this. See
42 * dom/script/ScriptSettings.h for details.
43 *
44 * If the embedding has the host defined data, this method should return the
45 * host defined data via the `data` out parameter and return `true`.
46 * The object in the `data` out parameter can belong to any compartment.
47 * If the embedding doesn't need the host defined data, this method should
48 * set the `data` out parameter to `nullptr` and return `true`.
49 * If any error happens while generating the host defined data, this method
50 * should set a pending exception to `cx` and return `false`.
51 */
52bool getHostDefinedData(JSContext *cx, JS::MutableHandle<JSObject *> data) const override;
53
54/**
55 * @brief Enqueue a reaction job `job` for `promise`, which was allocated at
56 * `allocationSite`. Provide `incumbentGlobal` as the incumbent global for
57 * the reaction job's execution.
58 *
59 * `promise` can be null if the promise is optimized out.
60 * `promise` is guaranteed not to be optimized out if the promise has
61 * non-default user-interaction flag.
62 */
63bool enqueuePromiseJob(JSContext *cx, JS::HandleObject promise,
64 JS::HandleObject job, JS::HandleObject allocationSite,
65 JS::HandleObject incumbentGlobal) override;
66
67/**
68 * @brief Run all jobs in the queue. Running one job may enqueue others; continue to
69 * run jobs until the queue is empty.
70 *
71 * Calling this method at the wrong time can break the web. The HTML spec
72 * indicates exactly when the job queue should be drained (in HTML jargon,
73 * when it should "perform a microtask checkpoint"), and doing so at other
74 * times can incompatibly change the semantics of programs that use promises
75 * or other microtask-based features.
76 *
77 * This method is called only via AutoDebuggerJobQueueInterruption, used by
78 * the Debugger API implementation to ensure that the debuggee's job queue is
79 * protected from the debugger's own activity. See the comments on
80 * AutoDebuggerJobQueueInterruption.
81 */

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected