Open LekhaSahdev opened 6 years ago
can not you run the same formula in parallel?
The objects on which it has to be run are dynamically generated based on client input. So we wont know precisely how many objects will get generated per expression.
One solution to this would be to make the Owner object a ThreadLocal object. Needs to happen in the expression code but that would be a breaking change because you would not be able to set the owner object in one thread and evaluate in another. You really need a separate expression for each thread as you are basically overwriting the data in the singularity. I think the request should be to be able to clone an expression without needing to recompile it, then you could clone the expression (hopefully a trivial task) and set a new Owner object on it to evaluate.
I realize it has been a few years, but since this issue is still flagged as OPEN and has no posts on how to deal with it, here is the solution.
IExpression has a Clone method. So, for each thread, clone the expression, set owner, and Evaluate.
We have certain complicated expressions to be evaluated per object parallely. For the compiled expression the owner is within the expression. Hence when we by run the same expression in parallel on different objects multi threading issues occur and result of one gets attached to another. Can you provide an override for evaluate wherein the same compiled expression i can evaluate on multiple objects