Alex
Alex

Reputation: 171

How to use isolate->terminateExecution to stop all threads

I understand that isolate->terminateExecution() only terminates the current thread. I've seen some suggestions on using v8::Locker to have to propagate and terminate all threads, however I'm unsure how this should work.

I'm running v8 version 8.1.

Upvotes: 0

Views: 149

Answers (1)

jmrk
jmrk

Reputation: 40786

Only one thread can be active in an Isolate at any time, so there is only one thread to terminate.

If your application has several threads, then there are two possible scenarios:

  • either your threads are taking turns at entering that Isolate, in which case you should have Lockers already. You should be able to add your own gating/bookkeeping without too much trouble (e.g. have a global flag that indicates "one thread has requested termination of the shared isolate, so no thread is allowed to enter it any more").
  • or each of your threads has its own Isolate, in which case they should each call TerminateExecution individually.

Upvotes: 1

Related Questions