Add DONE_CHECKING as a reason for requesting nodes.

Split registering the unique new deps of a node between those where we're enqueueing a known dependency from a prior build and one where we're adding a new dependency.

Replace prefetchBatch with getBatchAsync and add createIfAbsentBatchAsync.

PiperOrigin-RevId: 190471980
diff --git a/src/main/java/com/google/devtools/build/skyframe/QueryableGraph.java b/src/main/java/com/google/devtools/build/skyframe/QueryableGraph.java
index 8c5af09..4a1a31a 100644
--- a/src/main/java/com/google/devtools/build/skyframe/QueryableGraph.java
+++ b/src/main/java/com/google/devtools/build/skyframe/QueryableGraph.java
@@ -14,6 +14,7 @@
 package com.google.devtools.build.skyframe;
 
 import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadSafe;
+import com.google.errorprone.annotations.CanIgnoreReturnValue;
 import java.util.Map;
 import javax.annotation.Nullable;
 
@@ -50,12 +51,13 @@
           throws InterruptedException;
 
   /**
-   * A prefetch call may be used to hint to the graph that we may call {@link #getBatch} on the
-   * specified keys later.
+   * A version of {@link #getBatch} that returns an {@link InterruptibleSupplier} to possibly
+   * retrieve the results later.
    */
-  default void prefetchBatch(
+  @CanIgnoreReturnValue
+  default InterruptibleSupplier<Map<SkyKey, ? extends NodeEntry>> getBatchAsync(
       @Nullable SkyKey requestor, Reason reason, Iterable<? extends SkyKey> keys) {
-    // Do nothing.
+    return InterruptibleSupplier.Memoize.of(() -> getBatch(requestor, reason, keys));
   }
 
   /**
@@ -128,6 +130,9 @@
     /** The node is being looked up merely for an existence check. */
     EXISTENCE_CHECKING,
 
+    /** The node is being looked up merely to see if it is done or not. */
+    DONE_CHECKING,
+
     /**
      * The node is being looked up to service {@link WalkableGraph#getValue},
      * {@link WalkableGraph#getException}, {@link WalkableGraph#getMissingAndExceptions}, or