protected void finishArcTokenBacktrack(final ArcToken backtrackArcToken, final ArcToken parent) { arcTokenMap.put(parent, backtrackArcToken); NodeToken nodeTokenParent = parent.getParentToken(); if (visited.contains(nodeTokenParent)) { queue.add(nodeTokenParent); backtrackArcToken.markProcessed(); ArcTokenEvent.fireProcessedEvent(engine, backtrackArcToken); } else { parent.getProcess().enqueueArcTokenForExecution(backtrackArcToken); } }
public NodeToken backtrackDeadEnd(final NodeToken token) { token.markBacktracked(); NodeTokenEvent.fireBacktrackedEvent(engine, token); List<ArcToken> parents = new ArrayList<ArcToken>(token.getParentTokens().size()); for (ArcToken parent : token.getParentTokens()) { parent.markBacktracked(); ArcTokenEvent.fireBacktrackedEvent(engine, parent); ArcToken backtrackArcToken = engine .getFactory() .newArcToken(token.getProcess(), parent.getArc(), ExecutionType.UTurn, token); ArcTokenEvent.fireCreatedEvent(engine, backtrackArcToken); token.getChildTokens().add(backtrackArcToken); parents.add(backtrackArcToken); shareTokenSets(backtrackArcToken, parent); } NodeToken backtrackToken = engine .getFactory() .newNodeToken( token.getProcess(), token.getNode(), ExecutionType.Forward, parents, token); NodeTokenEvent.fireCreatedEvent(engine, backtrackToken); token.getProcess().addNodeToken(backtrackToken); shareTokenSets(backtrackToken, token); for (ArcToken parent : parents) { parent.markProcessed(); ArcTokenEvent.fireProcessedEvent(engine, parent); parent.markComplete(backtrackToken); ArcTokenEvent.fireCompletedEvent(engine, parent); } reactivateTokenSets(); return backtrackToken; }