Is IronRuby ScriptSource.Execute thread safe?
Asked Answered
A

1

3

We are implemented expression evaluator via hosting IronRuby engine. Simplified version of evaluator you can see here.

Now we are trying to get more performance from IronRuby via executing expressions in many threads (and we got it). One question bothers us - is Execute method thread safe?

Arturo answered 27/12, 2009 at 21:18 Comment(0)
T
5

ScriptRuntime, ScriptEngine, and ScriptScope are all thread safe, designed to be used between threads. Specifically, ScriptScope uses a thread-safe data-store, so ScriptScope can be shared between threads.

If you provide your own scope for scripts to execute against, you will need to ensure that scope's data store is thread-safe. Also, when mutating data in a ScriptScope, thread-safety is ensured by locking, so be aware that many different threads mutating a shared ScriptScope will degrade performance. Reading data from a ScriptScope does not lock.

Toughen answered 29/12, 2009 at 3:28 Comment(2)
Why were you using threads for perf, and how have you seen it degrade?Toughen
I just updated my answer, after finding out that the hosting API is in-fact thread-safe. This should make your performance boosts come back =)Toughen

© 2022 - 2024 — McMap. All rights reserved.