return localFireCount;
}
}
RuleTerminalNode rtn = (RuleTerminalNode) pmem.getNetworkNode();
RuleImpl rule = rtn.getRule();
LeftTuple leftTuple = getNextLeftTuple();
if (rule.isAllMatches()) {
agenda.fireConsequenceEvent((AgendaItem) leftTuple, DefaultAgenda.ON_BEFORE_ALL_FIRES_CONSEQUENCE_NAME);
}
LeftTuple lastLeftTuple = null;
for (; leftTuple != null; lastLeftTuple = leftTuple, leftTuple = getNextLeftTuple()) {
PropagationContext pctx = leftTuple.getPropagationContext();
pctx = RuleTerminalNode.findMostRecentPropagationContext(leftTuple, pctx);
//check if the rule is not effective or
// if the current Rule is no-loop and the origin rule is the same then return
if (cancelAndContinue(wm, rtn, rule, leftTuple, pctx, filter)) {
continue;
}
AgendaItem item = (AgendaItem) leftTuple;
if (agenda.getActivationsFilter() != null && !agenda.getActivationsFilter().accept(item, wm, rtn)) {
// only relevant for seralization, to not refire Matches already fired
continue;
}
agenda.fireActivation(item);
localFireCount++;
if (rtn.getLeftTupleSource() == null) {
break; // The activation firing removed this rule from the rule base
}
int salience = ruleAgendaItem.getSalience(); // dyanmic salience may have updated it, so get again.
if (queue != null && !queue.isEmpty() && salience != queue.peek().getSalience()) {
ruleAgendaItem.dequeue();
ruleAgendaItem.setSalience(queue.peek().getSalience());
ruleAgendaItem.getAgendaGroup().add(ruleAgendaItem);
salience = ruleAgendaItem.getSalience();
}
if (!rule.isAllMatches()) { // if firing rule is @All don't give way to other rules
RuleAgendaItem nextRule = agenda.peekNextRule();
if (haltRuleFiring(nextRule, fireCount, fireLimit, localFireCount, agenda, salience)) {
break; // another rule has high priority and is on the agenda, so evaluate it first
}
reEvaluateNetwork(wm, outerStack, fireUntilHalt);
wm.executeQueuedActions();
}
if (tupleList.isEmpty() && !outerStack.isEmpty()) {
// the outer stack is nodes needing evaluation, once all rule firing is done
// such as window expiration, which must be done serially
StackEntry entry = outerStack.removeFirst();
NETWORK_EVALUATOR.evalStackEntry(entry, outerStack, outerStack, this, wm);
}
}
if (rule.isAllMatches()) {
agenda.fireConsequenceEvent((AgendaItem) lastLeftTuple, DefaultAgenda.ON_AFTER_ALL_FIRES_CONSEQUENCE_NAME);
}
}
removeRuleAgendaItemWhenEmpty(wm);