You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
vals:=make(chan*v8.Value, 1)
errs:=make(chanerror, 1)
gofunc() {
val, err:=ctx.RunScript(script, "forever.js") // exec a long running scriptiferr!=nil {
errs<-errreturn
}
vals<-val
}()
select {
caseval:=<-vals:
// successcaseerr:=<-errs:
// javascript errorcase<-time.After(200*time.Milliseconds):
vm:=ctx.Isolate() // get the Isolate from the contextvm.TerminateExecution() // terminate the executionerr:=<-errs// will get a termination error back from the running script
}
i wanted to implement a memory limit for the isolate. so i implemented a ticker to check the limit with GetHeapStatistics. following this example, i called RunScript in a goroutine, and the terminate in the main routine. this caused fatal errors which i assume is because of this.
// NewIsolate creates a new V8 isolate. Only one thread may access
// a given isolate at a time, but different threads may access
// different isolates simultaneously.
i think the example should be refactored to have the TerminateExecution in a goroutine instead, or have a comment to warn about the usage.
The text was updated successfully, but these errors were encountered:
i wanted to implement a memory limit for the isolate. so i implemented a ticker to check the limit with GetHeapStatistics. following this example, i called RunScript in a goroutine, and the terminate in the main routine. this caused fatal errors which i assume is because of this.
i think the example should be refactored to have the TerminateExecution in a goroutine instead, or have a comment to warn about the usage.
The text was updated successfully, but these errors were encountered: