On Tue, Oct 25, 2022 at 3:41 AM Jianyong Chen <balusc...@gmail.com> wrote: > > I also have these questions and if any v8 experts(or people with > replated knowledge/experience) see this post please give us some > information about them. > > We are embedding v8 into our HTTP server and creating one isolate > per thread, which may run multiple JavaScript scripts concurrently > (in separate contexts). > > In case scripts run too long, we use a watchdog thread to kill the > worker thread, and inside the installed signal handler, we call > isolate->TerminateExecution to stop the script. Since the isolate > is running multiple scripts, we just want to kill the one which > really timed out but preserve others(CancelTerminateExecution?). > > Is that possible to achieve? If so, what should I pay attention to? > > Any advice will be appreciated!
Yes, that can be made to work. V8 unwinds the JS call stack until C++ code calls isolate->CancelTerminateExecution(). Assuming your execution contexts don't interleave (context A can't call functions from context B), then all you have to do is place CancelTerminateExecution calls in the right spots. If they do interleave, well, you're in for a rough time. No real way to make that work. -- -- 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/CAHQurc8B-u7GQg%3DP3p%3DXVECM5U6Oc2OrcsPwcc8W-yjTTNFRaw%40mail.gmail.com.