diff options
author | Paul Pazderski | 2020-02-07 12:25:27 +0000 |
---|---|---|
committer | Paul Pazderski | 2020-02-12 14:53:14 +0000 |
commit | 1174c3ba92868a02950e11aa138a63c5b3241fa8 (patch) | |
tree | a17cb8fd6c895417c30abdef66ab55d588745762 /org.eclipse.debug.core | |
parent | 641acbdd37d0a0c9773b3c8f4a686efd557b3a81 (diff) | |
download | eclipse.platform.debug-1174c3ba92868a02950e11aa138a63c5b3241fa8.tar.gz eclipse.platform.debug-1174c3ba92868a02950e11aa138a63c5b3241fa8.tar.xz eclipse.platform.debug-1174c3ba92868a02950e11aa138a63c5b3241fa8.zip |
Bug 550195 - Reduce wait time in runtime process terminationI20200216-1145I20200215-1800I20200215-0600I20200214-1800I20200214-0620I20200213-1800I20200213-1520I20200213-1210I20200213-1100I20200213-0640I20200212-1810I20200212-1800
Java 8 added a waitFor method with timeout for the Process class. Using
this instead of the plain Thread.sleep can reduce waiting time in some
situations from 500 ms down to 10 ms.
For the case that Process is not a native process and has no optimized
waitFor implementation the situation still improves since the terminated
check is performed every 100 ms instead every 500 ms.
Change-Id: I0fc54981b53615fbae14d46a6c82a9b85d64b035
Signed-off-by: Paul Pazderski <paul-eclipse@ppazderski.de>
Diffstat (limited to 'org.eclipse.debug.core')
-rw-r--r-- | org.eclipse.debug.core/core/org/eclipse/debug/core/model/RuntimeProcess.java | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/model/RuntimeProcess.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/model/RuntimeProcess.java index 8ee0a099d..1bfb08a1e 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/core/model/RuntimeProcess.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/model/RuntimeProcess.java @@ -20,6 +20,7 @@ import java.nio.charset.UnsupportedCharsetException; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; +import java.util.concurrent.TimeUnit; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.PlatformObject; @@ -219,7 +220,11 @@ public class RuntimeProcess extends PlatformObject implements IProcess { } catch (IllegalThreadStateException ie) { } try { - Thread.sleep(TIME_TO_WAIT_FOR_THREAD_DEATH); + if (process != null) { + process.waitFor(TIME_TO_WAIT_FOR_THREAD_DEATH, TimeUnit.MILLISECONDS); + } else { + Thread.sleep(TIME_TO_WAIT_FOR_THREAD_DEATH); + } } catch (InterruptedException e) { } attempts++; |