| 32 | } |
| 33 | |
| 34 | bool JobQueue::enqueuePromiseJob(JSContext *cx, |
| 35 | [[maybe_unused]] JS::HandleObject promise, |
| 36 | JS::HandleObject job, |
| 37 | [[maybe_unused]] JS::HandleObject allocationSite, |
| 38 | JS::HandleObject incumbentGlobal) { |
| 39 | |
| 40 | // Convert the `job` JS function to a Python function for event-loop callback |
| 41 | JS::RootedValue jobv(cx, JS::ObjectValue(*job)); |
| 42 | PyObject *callback = pyTypeFactory(cx, jobv); |
| 43 | |
| 44 | // Send job to the running Python event-loop |
| 45 | PyEventLoop loop = PyEventLoop::getRunningLoop(); |
| 46 | if (!loop.initialized()) return false; |
| 47 | |
| 48 | // Inform the JS runtime that the job queue is no longer empty |
| 49 | JS::JobQueueMayNotBeEmpty(cx); |
| 50 | |
| 51 | loop.enqueue(callback); |
| 52 | |
| 53 | Py_DECREF(callback); |
| 54 | return true; |
| 55 | } |
| 56 | |
| 57 | void JobQueue::runJobs(JSContext *cx) { |
| 58 | // Do nothing |
nothing calls this directly
no test coverage detected