On Tue, Aug 11, 2020 at 9:38 AM Ran Aizen <abbshrsou...@gmail.com> wrote: > > I saw the v8 description says: > > > Isolate represents an isolated instance of the V8 engine. V8 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. > > According to my understanding, it seems one isolate can be run in multiple > thread (not in same time), and multiple isolate can be managed in one thread. > > Because I want to use Isolate as the VM for my program in multi-tenant case, > so I read some of the v8 API, I found that `v8::Isolate` has some APIs like: > > - `Isolate::enter`, `Isolate::exit` > - `Isolate::TerminateExecution` > - `Isolate::CancelTerminateExecution` > - `Isolate::RequestInterrupt` > > So, is it possible to "schedule" massive isolates among multiple threads > using v8 public APIs like above or does v8 support to achieve the "schedule" ? > > The "schedule" here means maybe: > > 1. work stealing: let a thread run an isolate which was created and init by > other thread to balanced the isolate distribution. > 2. round-robin: one thread created multiple isolate, when an special event > happend (maybe recv an os signal), one of the running isolate could be paused > the execution progress, save the execution context and switch into other > isolate, after other isolate finished, resume the previous isolate's > execution.
I believe your question is whether V8 supports preemptive rescheduling, i.e., without cooperation from the executing script? It doesn't. It's allowed to call isolate->RequestInterrupt() and then call isolate->TerminateExecution() from the callback but not isolate->Exit(). -- -- 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/CAHQurc-Wa-6XKARB%2BWMRm6cq5QfsevkzXpCiRos7OUtQU6hjZg%40mail.gmail.com.