Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

" CompiledScript. Execute " thread safe? #95

Open
zgsxtyzgd opened this issue Mar 27, 2017 · 4 comments
Open

" CompiledScript. Execute " thread safe? #95

zgsxtyzgd opened this issue Mar 27, 2017 · 4 comments
Labels

Comments

@zgsxtyzgd
Copy link

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?

@paulbartrum
Copy link
Owner

paulbartrum commented Mar 27, 2017

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

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

@zgsxtyzgd
Copy link
Author

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

@paulbartrum
Copy link
Owner

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.

@zgsxtyzgd
Copy link
Author

Thank you very much, jurassic is doing extremely well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants