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

Method enqueuePromiseJob

src/JobQueue.cc:34–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32}
33
34bool 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
57void JobQueue::runJobs(JSContext *cx) {
58 // Do nothing

Callers

nothing calls this directly

Calls 3

pyTypeFactoryFunction · 0.85
initializedMethod · 0.80
enqueueMethod · 0.80

Tested by

no test coverage detected