11#ifndef PythonMonkey_JobQueue_
12#define PythonMonkey_JobQueue_
15#include <js/Promise.h>
35bool init(JSContext *cx);
56 JS::HandleObject job, JS::HandleObject allocationSite,
57 JS::HandleObject incumbentGlobal)
override;
74void runJobs(JSContext *cx)
override;
79bool empty()
const override;
104using FunctionVector = JS::GCVector<JSFunction *, 0, js::SystemAllocPolicy>;
105JS::PersistentRooted<FunctionVector> *finalizationRegistryCallbacks;
116js::UniquePtr<JS::JobQueue::SavedJobQueue> saveJobQueue(JSContext *)
override;
126static bool dispatchToEventLoop(
void *closure, JS::Dispatchable *dispatchable);
138static void promiseRejectionTracker(JSContext *cx,
bool mutedErrors,
139 JS::HandleObject promise, JS::PromiseRejectionHandlingState state,
bool sendJobToMainLoop(PyObject *pyFunc)
Send job to the Python event-loop on main thread (Thread-Safe)
Definition JobQueue.cc:113
Implement the ECMAScript Job Queue: https://www.ecma-international.org/ecma-262/9....
Definition JobQueue.hh:24
bool empty() const override
Definition JobQueue.cc:60
bool isDrainingStopped() const override
Definition JobQueue.cc:65
bool init(JSContext *cx)
Initialize PythonMonkey's event-loop job queue.
Definition JobQueue.cc:79
void queueFinalizationRegistryCallback(JSFunction *callback)
Appends a callback to the queue of FinalizationRegistry callbacks.
Definition JobQueue.cc:165
void runJobs(JSContext *cx) override
Run all jobs in the queue. Running one job may enqueue others; continue to run jobs until the queue i...
Definition JobQueue.cc:56
bool runFinalizationRegistryCallbacks(JSContext *cx)
Runs the accumulated queue of FinalizationRegistry callbacks.
Definition JobQueue.cc:169
bool enqueuePromiseJob(JSContext *cx, JS::HandleObject promise, JS::HandleObject job, JS::HandleObject allocationSite, JS::HandleObject incumbentGlobal) override
Enqueue a reaction job job for promise, which was allocated at allocationSite. Provide incumbentGloba...
Definition JobQueue.cc:33
JSObject * getIncumbentGlobal(JSContext *cx) override
Ask the embedding for the incumbent global.
Definition JobQueue.cc:29