mozilla / rhino

Rhino is an open-source implementation of JavaScript written entirely in Java
https://rhino.github.io
Other
4.19k stars 851 forks source link

Check for Thread.isInterrupted() when executing compiled scripts #49

Open ydewit opened 12 years ago

ydewit commented 12 years ago

This will enable Rhino to play nice with ThreadPoolExecutor when the client calls Future.cancel(true);

tonygermano commented 3 years ago

Considering this can also be done by the javascript developer in sections with long running code, where would be the appropriate place for the engine to insert all of these checks that are not part of the script being executed? After every statement or expression evaluation?

gbrail commented 3 years ago

This is a good use case for the "observer count" functionality in the Context class, which lets you get your arbitrary code called every N bytecode instructions. It only works with compiled code (opt level >= 0), however. But it lets you do this without any changes to Rhino.

p-bakker commented 3 years ago

Added the docs label, so once we have our new documentation in place, we can add some info to the docs about the observer count functionality