[quickjs-devel] Usage of QuickJS in multi-threaded environments

  • From: Alexander Rodin <rodin.alexander@xxxxxxxxx>
  • To: quickjs-devel@xxxxxxxxxxxxx
  • Date: Sun, 4 Aug 2019 19:39:52 +0300

Hi!

The documentation says the following about multi-threading support.

Inside a given runtime, no multi-threading is supported.

However, it is not clear to me would it be safe to move runtime between threads 
without concurrent access from different threads. In particular, I’m interested 
in the following use case:
1. Create a runtime in the first thread, make a few JS_Eval-s in it, ensure 
that JS_ExecutePendingJob returns 0.
2. Pass the pointers to JSContext and JSRuntime to the second thread.
3. Use JSContext and JSRuntime to run JS_Eval-s exclusively from the second 
thread.

I’m also interested would the described above behavior be different for enabled 
and disabled CONFIG_ATOMICS.

Thanks,
Alexander

Other related posts: