On 14/08/2019 16:32, Олег Кириенко wrote:
Hi,
I have wrote some tests with quickjs and libuv and found very convinient
to have notification about new promise jobs have been added. In that
case it is possible to start uv_prepare_t task to handle those new jobs.
Currently if do not have notification we need to check every time after
JS_Call or start uv_prepare_t task constantly which blocks event loop
from termination (if no other tasks are running)
So I have added handler for Job Notification
+typedef void JSJobNotificationHandler(JSRuntime *rt, void *opaque);
+void JS_SetJobNotificationHandler(JSRuntime *rt,
JSJobNotificationHandler *cb, void *opaque);
similar to interrupt handler which is called after job have been
enqueued to list
int JS_EnqueueJob(JSContext *ctx, JSJobFunc *job_func,
int argc, JSValueConst *argv)
{
...
list_add_tail(&e->link, &rt->job_list);
if (rt->notification_handler) {
rt->notification_handler(rt, rt->notification_opaque);
}
return 0;
}