jurassic icon indicating copy to clipboard operation
jurassic copied to clipboard

" CompiledScript. Execute " thread safe?

Open zgsxtyzgd opened this issue 8 years ago • 4 comments

CompiledScript. Execute(ScriptEngine engine) For different " ScriptEngine " Whether or not a thread - safe? Because the repeated use of " CompiledScript " can save a lot of parse time, but I don't know if this is appropriate?

zgsxtyzgd avatar Mar 27 '17 15:03 zgsxtyzgd

Yes, CompiledScript.Execute() should be thread-safe.

Edit: provided you use a different ScriptEngine for each thread.

paulbartrum avatar Mar 27 '17 21:03 paulbartrum

thank you. " EvalMethodGenerator " class in the parameter when it was new " scope " Can I use " ObjectScope.CreateGlobalPlaceholder ( ) "? Because I want to dynamically initializes, and saves some used similar (function(){...}) script MethodGenerator for repeated use. For this reason I changed MethodGenerator give it added a public object Execute(ScriptEngine engine,Scope scope,object thisObject) method example: //At initialization time var methodGen = new EvalMethodGenerator( ObjectScope.CreateGlobalPlaceholder(), source, // The source code. options ?? new CompilerOptions(), null); //When called var runtimeScope = ((ObjectScope)methodGen.InitialScope).ConvertPlaceholderToRuntimeScope(engine.Global); return methodGen.Execute(engine, runtimeScope, engine.Global); Do it, what would be the problem? --Sorry my English is very bad, please understand

zgsxtyzgd avatar Mar 28 '17 03:03 zgsxtyzgd

I'm not entirely sure what you're asking. I think what you're doing is essentially the same as what CompiledScript does, and therefore it should also be thread-safe.

paulbartrum avatar Mar 28 '17 03:03 paulbartrum

Thank you very much, jurassic is doing extremely well

zgsxtyzgd avatar Mar 28 '17 03:03 zgsxtyzgd