Ejemplo n.º 1
0
 private void updateAccumulatedBuildTime(BuildRuleEvent buildRuleEvent) {
   Optional<? extends BuildRuleEvent> started =
       Preconditions.checkNotNull(
           threadsToRunningBuildRuleEvent.put(
               buildRuleEvent.getThreadId(), Optional.<BuildRuleEvent>absent()));
   Preconditions.checkState(started.isPresent());
   Preconditions.checkState(buildRuleEvent.getBuildRule().equals(started.get().getBuildRule()));
   AtomicLong current = accumulatedRuleTime.get(buildRuleEvent.getBuildRule().getBuildTarget());
   // It's technically possible that another thread receives resumed and finished events
   // while we're processing this one, so we have to check that the current counter exists.
   if (current != null) {
     current.getAndAdd(buildRuleEvent.getTimestamp() - started.get().getTimestamp());
   }
 }