You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "SammyVimes (via GitHub)" <gi...@apache.org> on 2023/01/26 08:45:07 UTC

[GitHub] [ignite-3] SammyVimes commented on a diff in pull request #1579: IGNITE-18446 Add busy lock to raft service

SammyVimes commented on code in PR #1579:
URL: https://github.com/apache/ignite-3/pull/1579#discussion_r1087556788


##########
modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java:
##########
@@ -908,6 +909,32 @@ public static <T> List<T> collectStaticFields(Class<?> sourceCls, Class<? extend
         return result;
     }
 
+    /**
+     * Cancels the future and runs a consumer on future's result if it was completed before the cancellation.
+     * Does nothing if future is cancelled or completed exceptionally.
+     *
+     * @param future Future.
+     * @param consumer Consumer that accepts future's result.
+     * @param <T> Future's result type.
+     */
+    public static <T> void cancelOrConsume(CompletableFuture<T> future, Consumer<T> consumer) {
+        assert future != null;

Review Comment:
   ok, how about `@Contract("null -> fail")`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org