private void checkForCompletion(final GraphProcess process) { if (!process.hasActiveTokens() && process.isArcTokenQueueEmpty() && asyncQueue.isEmpty()) { process.setState(ProcessState.PendingCompletion); fireEvent(ProcessEvent.newCompletedEvent(this, process)); finalizeComplete(process); } }
@Override public void startProcess(GraphProcess process) { process.setState(ProcessState.Executing); fireEvent(ProcessEvent.newStartedEvent(this, process)); arcExecutionStarted = true; try { for (Node startNode : process.getGraph().getStartNodes()) { NodeToken startToken = getFactory().newNodeToken(process, startNode, new ArrayList<ArcToken>(0)); process.addNodeToken(startToken); executeNode(process, startToken); } executeQueuedArcTokens(process); } finally { arcExecutionStarted = false; drainAsyncQueue(process); } if (process.isExecuting()) { checkForCompletion(process); } }
@Override public void cancelProcess(GraphProcess process) { process.setState(ProcessState.PendingCancel); fireEvent(ProcessEvent.newCanceledEvent(this, process)); finalizeCancel(process); }