Description
In case of parallel process remember to create static objects separately for each process, otherwise you will get strange conflicts, errors as multiple processes will change the object state. So - If 8 processes then 8 different static functions.
Originally posted by @mariuszgromada in #134 (comment)
Is Function.calculate(params double[] parameters)
thread safe or not?
I have the following two pieces of code, one with a lock and the other one without
lock (_lock)
{
result = function.calculate(argumentValues);
}
result = function.calculate(argumentValues);
I am using many parallel threads calling function.calculate
on the same function
instance. The code without the lock seems to be much much much slower, I have not measured time, but I think it goes in seconds for some calculations instead of milliseconds for the code with the lock. Maybe this is caused by the locks that mxparser uses internally that are not FIFO?