fluxio / go-v8

Go bindings for the V8 JavaScript engine
Apache License 2.0
16 stars 5 forks source link

Add ctx.Unlocked() for long-running callbacks, add TerminatedError #4

Closed avaskys closed 7 years ago

avaskys commented 7 years ago

For long-running go callbacks that don't access JS at all, it is useful to unlock the isolate and allow other threads to use it while the callback is running. Added an Unlocked() function to the context to facilitate this.

Right now the Terminate() function exists (IMO incorrectly) on the context level even though the function will terminate any context that is currently running on the isolate. Unfortunately there doesn't appear to be an easy way to get V8 to terminate only a specific context. So added a TODO to move the function.

Because of this limitation, it would be nice to know if a context operation was spuriously terminated because another operation on another context in the isolate ran too long and timed out. So added a bunch of piping to return TerminatedError from a bunch of places.