[quickjs-devel] another stupid question about the pending job queue..

  • From: Mario Gliewe <mag@xxxxxxxxx>
  • To: quickjs-devel@xxxxxxxxxxxxx
  • Date: Thu, 19 Sep 2019 19:46:06 +0200

Hi again,

I found another step stone to stumble over :)

In the JSRuntime there is this job_list, one has to take care on the
context's eventloop (via JS_ExecutePendingJob()) ; so don't terminate
the loop until all jobs are done.

As far as I could see, this is only used to fulfill/reject Promises..

While this concept seems reasonable (afaik that's what the node.js
setImmediate() would do), I was wondering why the Timers in quickjs-libc
wouldn't use this mechanism?

And I was wondering why this list is bound to the JSRuntime rather to
the JSContext?

The reason I stumbled over this, was again the Worker-Interface, because
I cannot use the same runtime for different contexts in seperate threads
with this approach.

Even if I guarantee to never use the same JSValues across different
threads and synchronize gc(), the pending jobs would be executed in the
main-thread anyway.

greets

maG

PS:

Involved API interface: JS_EnqueueJob(), JS_IsJobPending(),
JS_ExecutePendingJob()




Other related posts: