Thank you Jakob, now I know it is fine to use multiple isolate in one thread. :-)
在 2019年12月19日星期四 UTC+8下午5:53:24,Jakob Kummerow写道: > > Sure, a single thread can use as many Isolates as it wants. Most V8 API > functions take an Isolate or a Context (which implies an Isolate) parameter > to facilitate this. > > Things to keep in mind: > - creating an Isolate is somewhat expensive, so creating millions of > short-lived Isolates is not great for performance. (Having dozens or even > hundreds of long-lived Isolates is perfectly fine.) > - objects (including functions, contexts, ...) are tied to the Isolate > they were created in. They can't be moved to, or executed in, or accessed > from another Isolate. > > > On Thu, Dec 19, 2019 at 8:25 AM Cooper Kuo <gkbi...@gmail.com > <javascript:>> wrote: > >> Hi, I am working out of a v8 embedder, I want to use multiple isolates at >> the same time, and these isolates should run in one thread, because there >> are some thrid-party framework api should be called inside main thread. >> >> In v8 official reference >> <https://v8docs.nodesource.com/node-12.0/d5/dda/classv8_1_1_isolate.html> >> about >> v8::Isolate: >> >> Isolate >>> <https://v8docs.nodesource.com/node-12.0/d5/dda/classv8_1_1_isolate.html> >>> represents >>> an isolated instance of the V8 >>> <https://v8docs.nodesource.com/node-12.0/df/d43/classv8_1_1_v8.html> >>> engine. V8 >>> <https://v8docs.nodesource.com/node-12.0/df/d43/classv8_1_1_v8.html> >>> isolates >>> have completely separate states. Objects from one isolate must not be used >>> in other isolates. The embedder can create multiple isolates and use them >>> in parallel in multiple threads. An isolate can be entered by at most one >>> thread at any given time. The Locker/Unlocker API must be used to >>> synchronize. >> >> >> It is apparently that I can use one isolate in one thread, even one >> isolate in multiple threads, but there is no description about "multiple >> isolates in one thread". >> >> -- >> -- >> v8-users mailing list >> v8-u...@googlegroups.com <javascript:> >> http://groups.google.com/group/v8-users >> --- >> You received this message because you are subscribed to the Google Groups >> "v8-users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to v8-u...@googlegroups.com <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/v8-users/ace604a3-1d78-4162-9e24-e161bb5cc9f6%40googlegroups.com >> >> <https://groups.google.com/d/msgid/v8-users/ace604a3-1d78-4162-9e24-e161bb5cc9f6%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/v8-users/a3c2d054-8084-41aa-9923-f00702b92687%40googlegroups.com.