-
Notifications
You must be signed in to change notification settings - Fork 952
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can quickjs be used in multithreading? #362
Comments
I don't know if Charlie and Fabrice intend to cherry-pick it but we fixed that in quickjs-ng almost a year ago to the day in commit quickjs-ng/quickjs@5ce2957e. |
thanks, I think this modification is good, classid is originally bound to the runtime, so creating a new one should not affect other runtimes. |
Yes, we shall cherry-pick this patch and many others |
Note that in normal cases you want to share the class ID between all the JSRuntimes so that they can easily communicate. In this case, locking is not needed and it explains the current code. |
* Add faster test262 test target - add test262-fast.conf with lengthy tests disabled - add test262-fast corresponding target - make valgrind use test262-fast
As shown in the code above, js_class_id_alloc is a global variable, and the same reference is used in all threads.
If different JSRuntimes are instantiated in different threads, and JS_NewClassID is called in each thread to generate a new classId, then the classId will not grow independently in each thread as expected, which should cause management problems for class_array in each JSRuntime.
ps: In addition, I found that calling quickjs API in multiple threads will cause some resource management problems, even in different JSRuntime instances.
The text was updated successfully, but these errors were encountered: