示例#1
0
    @Override
    public void run() {
      while (shouldWaitForWork()) {
        try (BuildTargetProcessingScope processingScope = startProcessingBuildTarget()) {
          // If we've already parsed this in another thread, we can skip doing any work.
          if (permState.hasCachedTargetNodeForBuildTarget(processingScope.getBuildTarget())) {
            continue;
          }
          TargetNode<?> node;
          try (SimplePerfEvent.Scope scope =
              Parser.getTargetNodeEventScope(eventBus, processingScope.getBuildTarget())) {
            try {
              node = getTargetNode(processingScope.getBuildTarget());
            } catch (BuildFileParseException | BuildTargetException | IOException e) {
              // It's okay to not raise this further up because in `Parser` we build the target
              // graph and while doing so will hit the same error (the parsing will have been
              // cached).
              abortDoingMoreWork();
              return;
            }
          }

          processingScope.addDepsToProcess(
              FluentIterable.from(node.getDeps())
                  .filter(permState.getHasCachedTargetNodeForBuildTargetPredicate())
                  .toSet());
        } catch (TimeoutException e) {
          // We timed out waiting to process something on the queue.  This could mean we are done,
          // so run through the while statement again.
          continue;
        } catch (InterruptedException e) {
          abortDoingMoreWork();
          return;
        }
      }
    }