io: Add BaseDataReader.waitFor(long, TimeUnit) appcode/171.958 clion/171.959
authorEldar Abusalimov <eldar.abusalimov@jetbrains.com>
Mon, 14 Nov 2016 09:50:16 +0000 (12:50 +0300)
committerEldar Abusalimov <eldar.abusalimov@jetbrains.com>
Mon, 14 Nov 2016 11:50:29 +0000 (14:50 +0300)
platform/util/src/com/intellij/util/io/BaseDataReader.java

index 62061de38fedc0572d6692a857ba9151d0649247..f6c523835f523bbce57463419216c94d12c3a2eb 100644 (file)
@@ -22,6 +22,8 @@ import org.jetbrains.annotations.NotNull;
 import java.io.IOException;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
 
 /**
  * @author Konstantin Kolosovsky.
@@ -212,4 +214,13 @@ public abstract class BaseDataReader {
       LOG.error(e);
     }
   }
-}
\ No newline at end of file
+
+  public void waitFor(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException {
+    try {
+      myFinishedFuture.get(timeout, unit);
+    }
+    catch (ExecutionException e) {
+      LOG.error(e);
+    }
+  }
+}