public void Dispose() { if (_query != null) { _query.Dispose(); } if (_prelude != null) { _prelude.Dispose(); } }
public void Dispose() { _disposed = true; if (_query != null) { _query.Dispose(); } if (_prelude != null) { _prelude.Dispose(); } }
public void long_execution_of_non_v8_code_does_not_crash() { Assert.Throws <Js1Exception>(() => { _cancelCallbackFactory = (timeout, action) => ThreadPool.QueueUserWorkItem(state => { Console.WriteLine("Calling a callback in " + timeout + "ms"); Thread.Sleep(timeout); action(); }); Action <string, object[]> logger = (m, _) => Console.WriteLine(m); Func <string, Tuple <string, string> > getModuleSource = name => { var fullScriptFileName = Path.GetFullPath(Path.Combine(_jsPath, name + ".js")); var scriptSource = File.ReadAllText(fullScriptFileName, Helper.UTF8NoBom); return(Tuple.Create(scriptSource, fullScriptFileName)); }; var preludeSource = getModuleSource("1Prelude"); var prelude = new PreludeScript(preludeSource.Item1, preludeSource.Item2, getModuleSource, _cancelCallbackFactory, logger); try { //var cancelToken = 123; prelude.ScheduleTerminateExecution(); Thread.Sleep(500); _commandHandlerRegisteredCallback = (name, handle) => { }; _reverseCommandHandlerDelegate = (name, body) => { }; Js1.CompileQuery( prelude.GetHandle(), "log(1);", "fn", _commandHandlerRegisteredCallback, _reverseCommandHandlerDelegate); prelude.CancelTerminateExecution(); } catch { prelude.Dispose(); // clean up unmanaged resources if failed to create throw; } }); }
public V8ProjectionStateHandler( string preludeName, string querySource, Func <string, Tuple <string, string> > getModuleSource, Action <string, object[]> logger, Action <int, Action> cancelCallbackFactory) { var preludeSource = getModuleSource(preludeName); var prelude = new PreludeScript(preludeSource.Item1, preludeSource.Item2, getModuleSource, cancelCallbackFactory, logger); QueryScript query; try { query = new QueryScript(prelude, querySource, "POST-BODY"); query.Emit += QueryOnEmit; } catch { prelude.Dispose(); // clean up unmanaged resources if failed to create throw; } _prelude = prelude; _query = query; }