mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-18 22:45:23 +02:00
After the weekly meeting, this cleanup was suggested.
It uses the Future class to extract the data we want.
This commit is contained in:
parent
ca383d57de
commit
945d387170
1 changed files with 29 additions and 27 deletions
|
@ -12,8 +12,8 @@ package org.eclipse.dd.gdb.internal.provisional.launching;
|
||||||
|
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
import java.util.concurrent.RejectedExecutionException;
|
import java.util.concurrent.RejectedExecutionException;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
|
||||||
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
@ -100,18 +100,19 @@ public class GdbLaunch extends Launch
|
||||||
public void addInferiorProcess(String label) throws CoreException {
|
public void addInferiorProcess(String label) throws CoreException {
|
||||||
try {
|
try {
|
||||||
// Add the "inferior" process object to the launch.
|
// Add the "inferior" process object to the launch.
|
||||||
final AtomicReference<MIInferiorProcess> inferiorProcessRef = new AtomicReference<MIInferiorProcess>();
|
Future<MIInferiorProcess> future =
|
||||||
getDsfExecutor().submit( new Callable<Object>() {
|
getDsfExecutor().submit( new Callable<MIInferiorProcess>() {
|
||||||
public Object call() throws CoreException {
|
public MIInferiorProcess call() throws CoreException {
|
||||||
GDBControl gdb = fTracker.getService(GDBControl.class);
|
GDBControl gdb = fTracker.getService(GDBControl.class);
|
||||||
if (gdb != null) {
|
if (gdb != null) {
|
||||||
inferiorProcessRef.set(gdb.getInferiorProcess());
|
return gdb.getInferiorProcess();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}).get();
|
});
|
||||||
|
MIInferiorProcess inferiorProc = future.get();
|
||||||
|
|
||||||
DebugPlugin.newProcess(this, inferiorProcessRef.get(), label);
|
DebugPlugin.newProcess(this, inferiorProc, label);
|
||||||
} catch (InterruptedException e) {
|
} 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$
|
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) {
|
} catch (ExecutionException e) {
|
||||||
|
@ -124,18 +125,19 @@ public class GdbLaunch extends Launch
|
||||||
public void addCLIProcess(String label) throws CoreException {
|
public void addCLIProcess(String label) throws CoreException {
|
||||||
try {
|
try {
|
||||||
// Add the CLI process object to the launch.
|
// Add the CLI process object to the launch.
|
||||||
final AtomicReference<AbstractCLIProcess> cliProcessRef = new AtomicReference<AbstractCLIProcess>();
|
Future<AbstractCLIProcess> future =
|
||||||
getDsfExecutor().submit( new Callable<Object>() {
|
getDsfExecutor().submit( new Callable<AbstractCLIProcess>() {
|
||||||
public Object call() throws CoreException {
|
public AbstractCLIProcess call() throws CoreException {
|
||||||
GDBControl gdb = fTracker.getService(GDBControl.class);
|
GDBControl gdb = fTracker.getService(GDBControl.class);
|
||||||
if (gdb != null) {
|
if (gdb != null) {
|
||||||
cliProcessRef.set(gdb.getCLIProcess());
|
return gdb.getCLIProcess();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}).get();
|
});
|
||||||
|
AbstractCLIProcess cliProc = future.get();
|
||||||
|
|
||||||
DebugPlugin.newProcess(this, cliProcessRef.get(), label);
|
DebugPlugin.newProcess(this, cliProc, label);
|
||||||
} catch (InterruptedException e) {
|
} 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$
|
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) {
|
} catch (ExecutionException e) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue