From 945d38717041a9bdc3b79e52f8f1674e23f0f91b Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Tue, 22 Apr 2008 19:25:58 +0000 Subject: [PATCH] After the weekly meeting, this cleanup was suggested. It uses the Future class to extract the data we want. --- .../provisional/launching/GdbLaunch.java | 56 ++++++++++--------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/launching/GdbLaunch.java b/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/launching/GdbLaunch.java index b5c797a9ae4..3e2bddda835 100644 --- a/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/launching/GdbLaunch.java +++ b/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/launching/GdbLaunch.java @@ -12,8 +12,8 @@ package org.eclipse.dd.gdb.internal.provisional.launching; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; import java.util.concurrent.RejectedExecutionException; -import java.util.concurrent.atomic.AtomicReference; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; @@ -98,20 +98,21 @@ public class GdbLaunch extends Launch public DsfSession getSession() { return fSession; } public void addInferiorProcess(String label) throws CoreException { - try { - // Add the "inferior" process object to the launch. - final AtomicReference inferiorProcessRef = new AtomicReference(); - getDsfExecutor().submit( new Callable() { - public Object call() throws CoreException { - GDBControl gdb = fTracker.getService(GDBControl.class); - if (gdb != null) { - inferiorProcessRef.set(gdb.getInferiorProcess()); - } - return null; - } - }).get(); - - DebugPlugin.newProcess(this, inferiorProcessRef.get(), label); + try { + // Add the "inferior" process object to the launch. + Future future = + getDsfExecutor().submit( new Callable() { + public MIInferiorProcess call() throws CoreException { + GDBControl gdb = fTracker.getService(GDBControl.class); + if (gdb != null) { + return gdb.getInferiorProcess(); + } + return null; + } + }); + MIInferiorProcess inferiorProc = future.get(); + + DebugPlugin.newProcess(this, inferiorProc, label); } catch (InterruptedException e) { throw new CoreException(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, 0, "Interrupted while waiting for get process callable.", e)); //$NON-NLS-1$ } catch (ExecutionException e) { @@ -124,18 +125,19 @@ public class GdbLaunch extends Launch public void addCLIProcess(String label) throws CoreException { try { // Add the CLI process object to the launch. - final AtomicReference cliProcessRef = new AtomicReference(); - getDsfExecutor().submit( new Callable() { - public Object call() throws CoreException { - GDBControl gdb = fTracker.getService(GDBControl.class); - if (gdb != null) { - cliProcessRef.set(gdb.getCLIProcess()); - } - return null; - } - }).get(); - - DebugPlugin.newProcess(this, cliProcessRef.get(), label); + Future future = + getDsfExecutor().submit( new Callable() { + public AbstractCLIProcess call() throws CoreException { + GDBControl gdb = fTracker.getService(GDBControl.class); + if (gdb != null) { + return gdb.getCLIProcess(); + } + return null; + } + }); + AbstractCLIProcess cliProc = future.get(); + + DebugPlugin.newProcess(this, cliProc, label); } catch (InterruptedException e) { throw new CoreException(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, 0, "Interrupted while waiting for get process callable.", e)); //$NON-NLS-1$ } catch (ExecutionException e) {