mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
NonBlockingReadAction: link factory method
GitOrigin-RevId: 718a3859b0c35ad69c6570619b264736c7812a4d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
f1604cd024
commit
68d07f42e4
@@ -16,6 +16,8 @@ import java.util.function.Consumer;
|
||||
* A utility for running non-blocking read actions in background thread.
|
||||
* "Non-blocking" means to prevent UI freezes, when a write action is about to occur, a read action can be interrupted by a
|
||||
* {@link com.intellij.openapi.progress.ProcessCanceledException} and then restarted.
|
||||
*
|
||||
* @see ReadAction#nonBlocking
|
||||
*/
|
||||
public interface NonBlockingReadAction<T> {
|
||||
|
||||
@@ -25,7 +27,7 @@ public interface NonBlockingReadAction<T> {
|
||||
* are completed.
|
||||
* @see com.intellij.openapi.project.DumbService
|
||||
*/
|
||||
@Contract(pure=true)
|
||||
@Contract(pure = true)
|
||||
NonBlockingReadAction<T> inSmartMode(@NotNull Project project);
|
||||
|
||||
/**
|
||||
@@ -34,21 +36,21 @@ public interface NonBlockingReadAction<T> {
|
||||
* are completed.
|
||||
* @see com.intellij.psi.PsiDocumentManager
|
||||
*/
|
||||
@Contract(pure=true)
|
||||
@Contract(pure = true)
|
||||
NonBlockingReadAction<T> withDocumentsCommitted(@NotNull Project project);
|
||||
|
||||
/**
|
||||
* @return a copy of this builder that cancels submitted read actions after they become obsolete.
|
||||
* An action is considered obsolete if any of the conditions provided using {@code expireWhen} returns true).
|
||||
* The conditions are checked inside a read action, either on a background or on the UI thread.
|
||||
* An action is considered obsolete if any of the conditions provided using {@code expireWhen} returns true).
|
||||
* The conditions are checked inside a read action, either on a background or on the UI thread.
|
||||
*/
|
||||
@Contract(pure=true)
|
||||
@Contract(pure = true)
|
||||
NonBlockingReadAction<T> expireWhen(@NotNull BooleanSupplier expireCondition);
|
||||
|
||||
/**
|
||||
* @return a copy of this builder that cancels submitted read actions once the specified disposable is disposed.
|
||||
*/
|
||||
@Contract(pure=true)
|
||||
@Contract(pure = true)
|
||||
NonBlockingReadAction<T> expireWith(@NotNull Disposable parentDisposable);
|
||||
|
||||
/**
|
||||
@@ -56,17 +58,17 @@ public interface NonBlockingReadAction<T> {
|
||||
* The read actions are still executed on background thread, but the callbacks on their completion
|
||||
* are invoked on UI thread, and no write action is allowed to interfere before that and possibly invalidate the result.
|
||||
*/
|
||||
@Contract(pure=true)
|
||||
@Contract(pure = true)
|
||||
NonBlockingReadAction<T> finishOnUiThread(@NotNull ModalityState modality, @NotNull Consumer<T> uiThreadAction);
|
||||
|
||||
/**
|
||||
* Submit this computation to be performed in a non-blocking read action on background thread. The returned promise
|
||||
* is completed on the same thread (in the same read action), or on UI thread if {@link #finishOnUiThread} has been called.
|
||||
*
|
||||
* @param backgroundThreadExecutor an executor to actually run the computation. Common examples are
|
||||
* {@link com.intellij.util.concurrency.NonUrgentExecutor#getInstance()} or
|
||||
* {@link AppExecutorUtil#getAppExecutorService()} or
|
||||
* {@link com.intellij.util.concurrency.BoundedTaskExecutor} on top of that.
|
||||
*/
|
||||
CancellablePromise<T> submit(@NotNull Executor backgroundThreadExecutor);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user