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

Method enqueue

src/PyEventLoop.cc:71–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69static PyMethodDef timerJobWrapperDef = {"timerJobWrapper", timerJobWrapper, METH_VARARGS, NULL};
70
71PyEventLoop::AsyncHandle PyEventLoop::enqueue(PyObject *jobFn) {
72 PyEventLoop::_locker->incCounter();
73 PyObject *wrapper = PyCFunction_New(&loopJobWrapperDef, jobFn);
74 // Enqueue job to the Python event-loop
75 // https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.loop.call_soon
76 PyObject *asyncHandle = PyObject_CallMethod(_loop, "call_soon_threadsafe", "O", wrapper);
77 return PyEventLoop::AsyncHandle(asyncHandle);
78}
79
80static PyObject *_enqueueWithDelay(PyObject *_loop, PyEventLoop::AsyncHandle::id_t handleId, PyObject *jobFn, double delaySeconds, bool repeat) {
81 PyObject *wrapper = PyCFunction_New(&timerJobWrapperDef, jobFn);

Callers 2

enqueuePromiseJobMethod · 0.80
sendJobToMainLoopFunction · 0.80

Calls 2

AsyncHandleClass · 0.85
incCounterMethod · 0.80

Tested by

no test coverage detected