From 256e07bed4d9dcd41b9ac66d2297b3ec8fd9ec08 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Fri, 30 Aug 2013 12:22:52 +0200 Subject: [PATCH] move ObsolescentAsyncResults to xdebugger --- .../xdebugger/ObsolescentAsyncResults.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 platform/xdebugger-api/src/com/intellij/xdebugger/ObsolescentAsyncResults.java diff --git a/platform/xdebugger-api/src/com/intellij/xdebugger/ObsolescentAsyncResults.java b/platform/xdebugger-api/src/com/intellij/xdebugger/ObsolescentAsyncResults.java new file mode 100644 index 000000000000..452f95f646ba --- /dev/null +++ b/platform/xdebugger-api/src/com/intellij/xdebugger/ObsolescentAsyncResults.java @@ -0,0 +1,38 @@ +package com.intellij.xdebugger; + +import com.intellij.openapi.util.AsyncResult; +import com.intellij.util.Consumer; +import com.intellij.util.PairConsumer; +import org.jetbrains.annotations.NotNull; + +public final class ObsolescentAsyncResults { + @NotNull + public static AsyncResult consume(@NotNull final AsyncResult result, + @NotNull final Obsolescent obsolescent, + @NotNull final Consumer consumer) { + result.doWhenDone(new Runnable() { + @Override + public void run() { + if (!obsolescent.isObsolete()) { + consumer.consume(result.getResult()); + } + } + }); + return result; + } + + @NotNull + public static AsyncResult consume(@NotNull final AsyncResult result, + @NotNull final O obsolescent, + @NotNull final PairConsumer consumer) { + result.doWhenDone(new Runnable() { + @Override + public void run() { + if (!obsolescent.isObsolete()) { + consumer.consume(result.getResult(), obsolescent); + } + } + }); + return result; + } +} \ No newline at end of file