-
-
Notifications
You must be signed in to change notification settings - Fork 102
EvalEngine
The EvalEngine class in Symja is responsible for the evaluation of expressions.
The EvalEngine class (or classes which delegate to EvalEngine) in Symja is not thread-safe. This means that it cannot be used concurrently by multiple threads without external synchronization. Here are the reasons why EvalEngine is not thread-safe:
EvalEngine maintains a mutable state that is shared among all threads. This includes variables, rules, and other settings. If multiple threads modify this state concurrently, it can lead to inconsistent and unpredictable results. This is a classic problem in concurrent programming known as a race condition.
EvalEngine does not use any synchronization mechanisms (like synchronized blocks or Lock objects) to control access to its internal state. This means that multiple threads can access and modify the state simultaneously, leading to data races and other concurrency issues.
EvalEngine uses thread-local storage for some of its data, which means that each thread has its own copy of this data. While this can help to avoid some concurrency issues, it also means that changes made by one thread are not visible to others. This can lead to inconsistencies if threads need to coordinate their actions or share results.
Some operations in EvalEngine are not atomic, meaning they involve multiple steps that should be completed as a single operation. If another thread interrupts these operations, it can leave the EvalEngine in an inconsistent state.
In conclusion, while EvalEngine is a powerful tool for symbolic computation, it is not designed to be used in a multithreaded environment without additional measures to ensure thread safety. If you need to use EvalEngine in a multi-threaded application, you should ensure that access to the engine is properly synchronized, or consider using separate EvalEngine instances for each thread.