From 4094cc0620d1c1aa87aa41c5cbed6d4dcbc36883 Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Tue, 12 May 2015 15:26:32 +0300 Subject: [PATCH] diff: javadoc --- .../diff/util/BackgroundTaskUtil.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/platform/diff-impl/src/com/intellij/diff/util/BackgroundTaskUtil.java b/platform/diff-impl/src/com/intellij/diff/util/BackgroundTaskUtil.java index 9cf267a06075..37493c5db27a 100644 --- a/platform/diff-impl/src/com/intellij/diff/util/BackgroundTaskUtil.java +++ b/platform/diff-impl/src/com/intellij/diff/util/BackgroundTaskUtil.java @@ -30,13 +30,24 @@ import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; -/* - * Executor to perform long operations on pooled thread - * Is is used to reduce blinking, in case of fast end of background task. - */ public class BackgroundTaskUtil { private static final Runnable TOO_SLOW_OPERATION = new EmptyRunnable(); + /* + * Executor to perform long operations on pooled thread + * It can be used to reduce blinking if background task completed fast. In this case callback will be called without invokeLater(). + * + * Simple approach: + * + * onSlowAction.run() // show "Loading..." + * executeOnPooledThread({ + * Runnable callback = backgroundTask(); // some background computations + * invokeLater(callback); // apply changes + * }); + * + * will lead to "Loading..." visible between current moment and execution of invokeLater() event. + * This period can be very short and looks like 'jumping' if background operation is fast. + */ @CalledInAwt @NotNull public static ProgressIndicator executeAndTryWait(@NotNull final Function backgroundTask,