This has been discussed a few times if you search this list. I think the last solution seemed to be:
Use preemption + terminate execution. The relevant stuff to look at would be: v8::Locker::StartPreemption and v8::V8::TerminateExecution Preemption would let you gain control even during infinite loops or infinite recursion. Terminate execution just stops js execution. I think what everyone is looking for is something like this for V8, just baked into the API: https://developer.mozilla.org/en/SpiderMonkey/JSAPI_Reference/JS_SetOperationCallback Set a callback function that is automatically called periodically while JavaScript code runs. If the callback returns JS_TRUE, the JS engine continues to execute the script. If the callback returns JS_FALSE without raising an exception, then the JS engine immediately stops running the script with an uncatchable error. On Aug 12, 12:30 pm, lei lu <[email protected]> wrote: > hi, > > thank u very much:) > i'll try it right now > > thanks > lei > > 2011/8/12 Mikhail Naganov <[email protected]>: > > > > > > > > > Hello, > > > You can interrupt VM execution from a parallel thread by executing > > v8::Debug::DebugBreak or v8::Debug::DebugBreakForCommand. Look into > > test/cctest/test-debug.cc for examples. > > > On Fri, Aug 12, 2011 at 15:54, Six <[email protected]> wrote: > >> hello all, sorry to disturb u. > > >> i have a problem that how i can invoke v8::Script::Run in async method > >> or can i set a time-out value for it? > >> because sometimes a js will take too long time. > > >> just like: > >> // compile > >> while (some condition) { > >> result = v8::Script::Run(); > >> // check the result > >> } > > >> if u have answer, please mail me. > >> thanks very much! > > >> lei > > >> -- > >> v8-users mailing list > >> [email protected] > >>http://groups.google.com/group/v8-users > > > -- > > v8-users mailing list > > [email protected] > >http://groups.google.com/group/v8-users -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
