Called by the worker when it has just created this FlowExpression and
 wants to apply it.
421061
def do_apply(msg)

      if msg['state'] == 'paused'

        return pause_on_apply(msg)
      end

      if msg['flavour'].nil? && (aw = attribute(:await))

        return await(aw, msg)
      end

      unless Condition.apply?(attribute(:if), attribute(:unless))

        return do_reply_to_parent(h.applied_workitem)
      end

      pi = h.parent_id
      reply_immediately = false

      if attribute(:scope).to_s == 'true'

        h.variables ||= {}
      end

      if attribute(:forget).to_s == 'true'

        h.variables = compile_variables
        h.parent_id = nil
        h.forgotten = true

        reply_immediately = true

      elsif attribute(:lose).to_s == 'true'

        h.lost = true

      elsif msg['flanking'] or (attribute(:flank).to_s == 'true')

        h.flanking = true

        reply_immediately = true
      end

      if reply_immediately and pi

        @context.storage.put_msg(
          'reply',
          'fei' => pi,
          'workitem' => Ruote.fulldup(h.applied_workitem),
          'flanking' => h.flanking)
      end

      filter

      consider_tag
      consider_timers

      apply
    end
388572
public function onBeforeWrite()
    {
        $this->owner->GoogleVerificationCode    = $this->getVerificationCode($this->owner->GoogleVerificationCode);
        $this->owner->GoogleAnalyticsTrackingID = trim($this->owner->GoogleAnalyticsTrackingID);
    }
519106
private void startWorkers(final ExecutorService executorService, final int numTasks) {
        for (int i = 0; i < numTasks; i++) {
            workerFutures.add(executorService.submit(new Callable<Void>() {
                @Override
                public Void call() throws Exception {
                    runWorkLoop();
                    return null;
                }
            }));
        }
    }
548923
public function onBeforeWrite()
    {
        parent::onBeforeWrite();

        $vars = $this->record;

        if (isset($vars['DirectUpdate'])) {
            // Unset now so that we don't end up in an infinite loop!
            unset($this->record['DirectUpdate']);
            $this->updateWorkflow($vars);
        }
    }
872861
public void execute() throws DataflowAnalysisException {
        boolean change;
        boolean debugWas = DEBUG;
        if (DEBUG) {
            reportAnalysis("Executing");
        }

        int timestamp = 0;
        boolean firstTime = true;
        do {
            change = false;
            boolean sawBackEdge = false;
            ++numIterations;
            if (numIterations > MAX_ITERS && !DEBUG) {
                DEBUG = true;
                reportAnalysis("Too many iterations");
                System.out.println(this.getClass().getName());
                if (this.getClass() == UnconditionalValueDerefDataflow.class || this.getClass() == LiveLocalStoreDataflow.class) {
                    try {
                        ClassContext cc = Global.getAnalysisCache().getClassAnalysis(ClassContext.class,
                                DescriptorFactory.createClassDescriptorFromDottedClassName(cfg.getMethodGen().getClassName()));
                        System.out.println("Forwards cfg");
                        CFGPrinter printer = new CFGPrinter(cfg);
                        printer.setIsForwards(true);
                        printer.print(System.out);
                        System.out.println("Backwards cfg");
                        printer = new CFGPrinter(cfg);
                        printer.setIsForwards(false);
                        printer.print(System.out);
                        cc.dumpSimpleDataflowInformation(cfg.getMethodGen().getMethod());
                    } catch (CheckedAnalysisException e) {
                        e.printStackTrace(System.out);
                    }
                }
            }

            if (DEBUG) {
                System.out.println("----------------------------------------------------------------------");
                System.out.println(this.getClass().getName() + " iteration: " + numIterations + ", timestamp: " + timestamp);
                MethodGen mg = cfg.getMethodGen();
                System.out.println(mg.getClassName() + "." + mg.getName() + mg.getSignature());
                System.out.println("----------------------------------------------------------------------");

            }

            if (numIterations >= MAX_ITERS + 9) {
                throw new DataflowAnalysisException("Too many iterations (" + numIterations + ") in dataflow when analyzing "
                        + getFullyQualifiedMethodName());
            }

            analysis.startIteration();

            if (DEBUG && firstTime && blockOrder instanceof ReverseDFSOrder) {
                ReverseDFSOrder rBlockOrder = (ReverseDFSOrder) blockOrder;
                System.out.println("Entry point is: " + logicalEntryBlock());
                System.out.println("Basic block order: ");
                Iterator<BasicBlock> i = blockOrder.blockIterator();
                while (i.hasNext()) {

                    BasicBlock block = i.next();
                    debug(block, "rBlockOrder " + rBlockOrder.rdfs.getDiscoveryTime(block) + "\n");
                }
            }
            Iterator<BasicBlock> i = blockOrder.blockIterator();
            if (numIterations > 3 && numIterations % 2 == 0 && blockOrder instanceof ReverseDFSOrder) {
                if (DEBUG) {
                    System.out.println("Trying program order");
                }
                TreeSet<BasicBlock> bb = new TreeSet<>(new BackwardProgramOrder());
                Iterator<BasicBlock> j = blockOrder.blockIterator();
                while (j.hasNext()) {
                    BasicBlock block = j.next();
                    bb.add(block);
                }
                if (DEBUG) {
                    for (BasicBlock block : bb) {
                        debug(block, "\n");
                    }
                }
                i = bb.iterator();
            }
            if (DEBUG) {
                dumpDataflow(analysis);
            }

            // For each block in CFG...

            while (i.hasNext()) {

                BasicBlock block = i.next();

                // Get start fact for block.
                Fact start = analysis.getStartFact(block);
                assert start != null;

                boolean needToRecompute = false;
                // Get result facts for block,
                Fact result = analysis.getResultFact(block);
                assert result != null;

                int originalResultTimestamp = analysis.getLastUpdateTimestamp(result);

                // Meet all of the logical predecessor results into this block's
                // start.
                // Special case: if the block is the logical entry, then it gets
                // the special "entry fact".
                if (block == logicalEntryBlock()) {
                    analysis.makeFactTop(start);
                    analysis.initEntryFact(start);
                    if (DEBUG) {
                        debug(block, "Init entry fact ==> " + analysis.factToString(start) + "\n");
                    }
                    needToRecompute = true;
                } else {
                    int lastCalculated = analysis.getLastUpdateTimestamp(start);
                    Iterator<Edge> predEdgeIter = logicalPredecessorEdgeIterator(block);

                    int predCount = 0;
                    int rawPredCount = 0;
                    while (predEdgeIter.hasNext()) {
                        Edge edge = predEdgeIter.next();
                        rawPredCount++;
                        if (needToRecompute) {
                            // don't need to check to see if we need to recompute.
                            if (firstTime && !sawBackEdge) {
                                // may need to se sawBackEdge
                            } else {
                                continue;
                            }

                        }
                        BasicBlock logicalPred = isForwards ? edge.getSource() : edge.getTarget();

                        int direction = blockOrder.compare(block, logicalPred);

                        if (DEBUG) {
                            debug(block, "direction " + direction + " for " + blockId(logicalPred) + "\n");
                        }
                        if (direction < 0) {
                            sawBackEdge = true;
                        }

                        // Get the predecessor result fact
                        Fact predFact = analysis.getResultFact(logicalPred);
                        int predLastUpdated = analysis.getLastUpdateTimestamp(predFact);
                        if (!analysis.isTop(predFact)) {
                            predCount++;
                            if (predLastUpdated >= lastCalculated) {

                                needToRecompute = true;
                                if (DEBUG) {
                                    debug(block, "\n Need to recompute. My timestamp = " + lastCalculated + ", pred timestamp = "
                                            + predLastUpdated + ",\n   pred fact = " + predFact + "\n");
                                }
                                // break;
                            }
                        }
                    }
                    if (predCount == 0) {
                        needToRecompute = true;
                    }

                    if (!needToRecompute) {
                        continue;
                    }

                    analysis.makeFactTop(start);
                    predEdgeIter = logicalPredecessorEdgeIterator(block);
                    while (predEdgeIter.hasNext()) {
                        Edge edge = predEdgeIter.next();
                        BasicBlock logicalPred = isForwards ? edge.getSource() : edge.getTarget();

                        // Get the predecessor result fact
                        Fact predFact = analysis.getResultFact(logicalPred);

                        // Apply the edge transfer function.
                        Fact edgeFact = analysis.createFact();
                        analysis.copy(predFact, edgeFact);
                        analysis.edgeTransfer(edge, edgeFact);

                        if (DEBUG && !analysis.same(edgeFact, predFact)) {
                            debug(block, logicalPred, edge, "Edge transfer " + analysis.factToString(predFact) + " ==> "
                                    + analysis.factToString(edgeFact));
                        }

                        // Merge the predecessor fact (possibly transformed
                        // by the edge transfer function)
                        // into the block's start fact.
                        if (DEBUG) {
                            if (analysis.isTop(start)) {
                                debug(block, logicalPred, edge, "\n  First pred is " + analysis.factToString(edgeFact)
                                        + "\n   last updated at " + analysis.getLastUpdateTimestamp(predFact) + "\n");
                            } else {
                                debug(block, logicalPred, edge, "\n  Meet " + analysis.factToString(start) + "\n   with "
                                        + analysis.factToString(edgeFact)

                                        + "\n   pred last updated at " + analysis.getLastUpdateTimestamp(predFact) + "\n");
                            }
                        }

                        if (analysis instanceof UnconditionalValueDerefAnalysis) {
                            ((UnconditionalValueDerefAnalysis) analysis).meetInto((UnconditionalValueDerefSet) edgeFact,
                                    edge, (UnconditionalValueDerefSet) start, rawPredCount == 1);
                        } else {
                            analysis.meetInto(edgeFact, edge, start);
                        }
                        analysis.setLastUpdateTimestamp(start, timestamp);

                        int pos = -1;
                        if (block.getFirstInstruction() != null) {
                            pos = block.getFirstInstruction().getPosition();
                        }
                        if (DEBUG) {
                            System.out.println(" [" + pos + "]==> " + analysis.factToString(start) + " @ " + timestamp
                                    + " \n");
                        }
                    }
                }
                if (DEBUG) {
                    debug(block, "start fact is " + analysis.factToString(start) + "\n");
                }

                // making a copy of result facts (so we can detect if it
                // changed).
                boolean resultWasTop = analysis.isTop(result);
                Fact origResult = null;
                if (!resultWasTop) {
                    origResult = analysis.createFact();
                    analysis.copy(result, origResult);
                }

                //                if (true || analysis.isTop(start)) {
                // Apply the transfer function.

                analysis.transfer(block, null, start, result);
                //                } else {
                //                    analysis.copy(start, result);
                //                }

                if (DEBUG && SystemProperties.getBoolean("dataflow.blockdebug")) {
                    debug(block, "Dumping flow values for block:\n");
                    Iterator<InstructionHandle> ii = block.instructionIterator();
                    while (ii.hasNext()) {
                        InstructionHandle handle = ii.next();
                        Fact tmpResult = analysis.createFact();
                        analysis.transfer(block, handle, start, tmpResult);
                        System.out.println("\t" + handle + " " + analysis.factToString(tmpResult));
                    }
                }

                // See if the result changed.
                if (DEBUG) {
                    debug(block, "orig result is " + (origResult == null ? "TOP" : analysis.factToString(origResult)) + "\n");
                }
                boolean thisResultChanged = false;
                if (resultWasTop) {
                    thisResultChanged = !analysis.isTop(result);
                } else {
                    thisResultChanged = !analysis.same(result, origResult);
                }
                if (thisResultChanged) {
                    timestamp++;
                    if (DEBUG) {
                        debug(block, "result changed at timestamp " + timestamp + "\n");
                    }
                    if (DEBUG && !needToRecompute) {
                        System.out.println("I thought I didn't need to recompute");
                    }
                    change = true;
                    analysis.setLastUpdateTimestamp(result, timestamp);
                } else {
                    analysis.setLastUpdateTimestamp(result, originalResultTimestamp);
                }

                if (DEBUG) {
                    debug(block,
                            "result is " + analysis.factToString(result) + " @ timestamp "
                                    + analysis.getLastUpdateTimestamp(result) + "\n");
                }
            }

            analysis.finishIteration();
            if (!sawBackEdge) {
                break;
            }

        } while (change);

        if (DEBUG) {
            System.out.println("-- Quiescence achieved-------------------------------------------------");
            System.out.println(this.getClass().getName() + " iteration: " + numIterations + ", timestamp: " + timestamp);
            MethodGen mg = cfg.getMethodGen();
            System.out.println(mg.getClassName() + "." + mg.getName() + mg.getSignature());
            new RuntimeException("Quiescence achieved----------------------------------------------------------------")
            .printStackTrace(System.out);

        }
        DEBUG = debugWas;
    }
999700
private void visitParentExpression(AbstractFunctionExpression parentExpr) {

        if (nextFunctionBodyStart == null) {
            nextFunctionBodyStart = parentExpr;
        }

        if (currentFunctionName != null) {
            updateCurrentFunction(parentExpr);
        } else {
            createFunctionIfNeeded(parentExpr);
        }

        if (GremlinQueryOptimizer.isOrExpression(parentExpr)) {
            //reset
            currentFunctionName = null;
            //don't include 'or' in generated functions
            nextFunctionBodyStart = null;
        }

    }
601719
protected void initialize() {
    // TODO(user): Calling clear doesn't deallocate the memory in a
    // LinkedHashSet. Consider creating a new work set if we plan to repeatedly
    // call analyze.
    orderedWorkSet.clear();
    for (DiGraphNode<N, Branch> node : cfg.getDirectedGraphNodes()) {
      node.setAnnotation(new FlowState<>(createInitialEstimateLattice(),
          createInitialEstimateLattice()));
      if (node != cfg.getImplicitReturn()) {
        orderedWorkSet.add(node);
      }
    }
  }
1028120
function Flow(flowControlId) {
  Duplex.call(this, { objectMode: true });

  this._window = this._initialWindow = INITIAL_WINDOW_SIZE;
  this._flowControlId = flowControlId;
  this._queue = [];
  this._ended = false;
  this._received = 0;
  this._blocked = false;
}
967269
private void dispatch(final ExecutionReference reference, final ExecutableFlow exflow,
      final Executor choosenExecutor) throws ExecutorManagerException {
    exflow.setUpdateTime(System.currentTimeMillis());

    this.executorLoader.assignExecutor(choosenExecutor.getId(),
        exflow.getExecutionId());
    try {
      this.apiGateway.callWithExecutable(exflow, choosenExecutor,
          ConnectorParams.EXECUTE_ACTION);
    } catch (final ExecutorManagerException ex) {
      logger.error("Rolling back executor assignment for execution id:"
          + exflow.getExecutionId(), ex);
      this.executorLoader.unassignExecutor(exflow.getExecutionId());
      throw new ExecutorManagerException(ex);
    }
    reference.setExecutor(choosenExecutor);

    // move from flow to running flows
    this.runningExecutions.get().put(exflow.getExecutionId(), new Pair<>(reference, exflow));
    synchronized (this.runningExecutions.get()) {
      // Wake up RunningExecutionsUpdaterThread from wait() so that it will immediately check status
      // from executor(s). Normally flows will run at least some time and can't be cleaned up
      // immediately, so there will be another wait round (or many, actually), but for unit tests
      // this is significant to let them run quickly.
      this.runningExecutions.get().notifyAll();
    }
    synchronized (this) {
      // wake up all internal waiting threads, too
      this.notifyAll();
    }

    logger.info(String.format(
        "Successfully dispatched exec %d with error count %d",
        exflow.getExecutionId(), reference.getNumErrors()));
  }
390358
function create(context) {
    return {
        CallExpression(node) {
            if (isNamedDefine(node)) {
                context.report(node, message);
            }
        }
    };
}
122435
public synchronized void afterPreviousWorkersFinished(ActorRef<WorkerListener> onFinished) {
        if (this.onFinished != null) {
            throw new IllegalStateException("a callback already exists; wait for the workers to finish before setting a new callback");
        }
        this.onFinished = onFinished;
        if (activeWorkers.get() == 0) {
            fireAllWorkersFinished();
        }
    }
802002
public void postProcess() {
    if (!this.isEmptySlot()) {

      switch (savedItem.getExpressionItemType()) {
        case OPERATOR: {
          if (savedItem == OPERATOR_SUB) {
            if (!childElements[0].isEmptySlot() && childElements[1].isEmptySlot()) {
              final ExpressionTreeElement left = childElements[0];
              final ExpressionItem item = left.getItem();
              if (item.getExpressionItemType() == ExpressionItemType.VALUE) {
                final Value val = (Value) item;
                switch (val.getType()) {
                  case INT: {
                    childElements = EMPTY;
                    savedItem = Value.valueOf(0 - val.asLong());
                    makeMaxPriority();
                  }
                  break;
                  case FLOAT: {
                    childElements = EMPTY;
                    savedItem = Value.valueOf(0.0f - val.asFloat());
                    makeMaxPriority();
                  }
                  break;
                  default: {
                    if (!left.isEmptySlot()) {
                      left.postProcess();
                    }
                  }
                  break;
                }
              }
            } else {
              for (final ExpressionTreeElement element : childElements) {
                if (!element.isEmptySlot()) {
                  element.postProcess();
                }
              }
            }
          } else {
            for (final ExpressionTreeElement element : childElements) {
              if (!element.isEmptySlot()) {
                element.postProcess();
              }
            }
          }
        }
        break;
        case FUNCTION: {
          for (final ExpressionTreeElement element : childElements) {
            if (!element.isEmptySlot()) {
              element.postProcess();
            }
          }
        }
        break;
      }
    }
  }
435837
def start_workflow(flow)
      @http.post(
        instance_worker_url,
        ATTR_PROG => PROG,
        ATTR_CANONICAL => canonical_name(flow),
        ATTR_NAME => class_name(flow),
        ATTR_DATA => @serializer.encode(@properties.from(flow)),
        ATTR_ID => parse_custom_id_from(flow)
      )
    end
889251
@Override
    public void onCreate() {
        super.onCreate();

        graphMonitor = new Graph.Monitor() {
            @Override
            public void onInject(Object target) {
                if (controller != null && target == MvcService.this) {
                    controller.view = MvcService.this;
                }
            }

            @Override
            public void onRelease(Object target) {

            }
        };
        Mvc.graph().registerMonitor(graphMonitor);

        if (getControllerClass() != null) {
            try {
                controller = Mvc.graph().reference(getControllerClass(), null);
            } catch (CircularDependenciesException e) {
                e.printStackTrace();
            } catch (ProvideException e) {
                e.printStackTrace();
            } catch (ProviderMissingException e) {
                throw new IllegalStateException("Unable to inject "
                        + getControllerClass().getName() + ".\n" + e.getMessage(), e);
            }
        }

        Mvc.graph().inject(this);

        eventRegister = new EventRegister(this);
        eventRegister.registerEventBuses();
    }
1353988
private void created() {
        String t = getTheme();
        if (t != null && !t.isEmpty()) setTheme(t);
    }
709378
private void invoke(Method method, Object event, InputContext inputContext) throws Exception {
    if (needContext) {
      method.invoke(flowlet, event, inputContext);
    } else {
      method.invoke(flowlet, event);
    }
  }
243403
public final synchronized void initialize(Object flowOwner)
    {
        if(this.initialized)
        {
            throw new FaxException("Vendor policy already initialized.");
        }
        
        if(flowOwner==null)
        {
            throw new FaxException("Flow owner not provided.");
        }

        //set flag
        this.initialized=true;

        //get flow owner
        this.vendorPolicyFlowOwner=flowOwner;
        
        //initialize
        this.initializeImpl();
    }