Author: adietish
Date: 2011-07-08 04:08:40 -0400 (Fri, 08 Jul 2011)
New Revision: 32744
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/LocalJBossBehaviorDelegate.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ThreadUtils.java
Log:
[JBIDE-9215] extracted waiting code from LocalJBossBehaviourDelegate#gracefulStop to
ThreadUtils#sleepWhileRunning(IProcess),
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/LocalJBossBehaviorDelegate.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/LocalJBossBehaviorDelegate.java 2011-07-08
07:59:57 UTC (rev 32743)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/LocalJBossBehaviorDelegate.java 2011-07-08
08:08:40 UTC (rev 32744)
@@ -43,6 +43,7 @@
import org.jboss.ide.eclipse.as.core.util.LaunchConfigUtils;
import org.jboss.ide.eclipse.as.core.util.PollThreadUtils;
import org.jboss.ide.eclipse.as.core.util.RuntimeUtils;
+import org.jboss.ide.eclipse.as.core.util.ThreadUtils;
/**
*
@@ -95,7 +96,7 @@
new LocalStopLaunchConfigurator(getServer()).configure(wc);
ILaunch launch = wc.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor());
IProcess stopProcess = launch.getProcesses()[0];
- waitFor(stopProcess);
+ ThreadUtils.sleepWhileRunning(stopProcess);
if (stopProcess.getExitValue() == 0) {
// TODO: correct concurrent access to process, pollThread and
nextStopRequiresForce
if( isProcessRunning() ) {
@@ -109,16 +110,6 @@
}
}
-
- private void waitFor(IProcess process) {
- while( !process.isTerminated()) {
- try {
- Thread.yield();
- Thread.sleep(100);
- } catch(InterruptedException ie) {
- }
- }
- }
}.start();
// TODO: find out if this is ok. My current guess is that we should
// not thread here and return the real outcome
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ThreadUtils.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ThreadUtils.java 2011-07-08
07:59:57 UTC (rev 32743)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/ThreadUtils.java 2011-07-08
08:08:40 UTC (rev 32744)
@@ -10,12 +10,16 @@
******************************************************************************/
package org.jboss.ide.eclipse.as.core.util;
+import org.eclipse.debug.core.model.IProcess;
+
/**
* @Rob Stryker
* @author André Dietisheim
*/
public class ThreadUtils {
+ private static final int SLEEP_DELAY = 200;
+
/**
* Sleeps the current thread for the given amount of milliseconds. InterruptedException
are swallowed.
*
@@ -26,10 +30,20 @@
while( x < delay) {
x+=200;
try {
- Thread.sleep(200);
+ Thread.sleep(SLEEP_DELAY);
} catch(InterruptedException ie) {
}
}
}
+
+ public static void sleepWhileRunning(IProcess process) {
+ while( !process.isTerminated()) {
+ try {
+ Thread.yield();
+ Thread.sleep(SLEEP_DELAY);
+ } catch(InterruptedException ie) {
+ }
+ }
+ }
}
Show replies by date