Created
March 12, 2021 01:22
-
-
Save tkobayas/1044be7c0760ed1c426a1b84157cc0d4 to your computer and use it in GitHub Desktop.
fully synchronized MVELConditionEvaluator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected boolean evaluate(InternalFactHandle handle, InternalWorkingMemory workingMemory, Tuple tuple) { | |
if (!jitted) { | |
int jittingThreshold = TEST_JITTING ? 0 : workingMemory.getKnowledgeBase().getConfiguration().getJittingThreshold(); | |
if (conditionEvaluator == null) { | |
if (jittingThreshold == 0 && !isDynamic) { // Only for test purposes or when jitting is enforced at first evaluation | |
synchronized (this) { | |
if (conditionEvaluator == null) { | |
conditionEvaluator = forceJitEvaluator(handle, workingMemory, tuple); | |
} | |
} | |
} else { | |
synchronized (this) { | |
if (conditionEvaluator == null) { | |
conditionEvaluator = createMvelConditionEvaluator(workingMemory); | |
} | |
} | |
} | |
} | |
if (jittingThreshold != 0 && !isDynamic && invocationCounter.getAndIncrement() == jittingThreshold) { | |
jitEvaluator(handle, workingMemory, tuple); | |
} | |
} | |
try { | |
if (conditionEvaluator instanceof MVELConditionEvaluator) { | |
synchronized (this) { | |
return conditionEvaluator.evaluate(handle, workingMemory, tuple); | |
} | |
} else { | |
return conditionEvaluator.evaluate(handle, workingMemory, tuple); | |
} | |
} catch (Exception e) { | |
throw new RuntimeException("Error evaluating constraint '" + expression + "' in " + evaluationContext, e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment