1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-06 09:16:02 +02:00

[292271] Guard against RejectedExecutionExceptions. Also, DsfServicesTracker.dispose() is now ThreadSafe so does not need to be called in the executor, which is good because we should still make this call even in the case of a RejectedExecution exception.

This commit is contained in:
Marc Khouzam 2009-10-15 20:17:34 +00:00
parent ee3801c51f
commit 06b3823732
2 changed files with 50 additions and 36 deletions

View file

@ -20,6 +20,7 @@ import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.RejectedExecutionException;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.debug.core.CDIDebugModel;
@ -2362,21 +2363,23 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
if (fTargetContext != null) {
if (fDebugSessionId != null) {
if (getSession() != null) {
// Store the values that we are going to change
final DsfSession session = getSession();
final DsfServicesTracker trackerToDispose= fServicesTracker;
session.getExecutor().execute(new DsfRunnable() {
public void run() {
session.removeServiceEventListener(DisassemblyPart.this);
if (trackerToDispose != null) {
trackerToDispose.dispose();
}
}
});
try {
// Store the values that we are going to change
final DsfSession session = getSession();
session.getExecutor().execute(new DsfRunnable() {
public void run() {
session.removeServiceEventListener(DisassemblyPart.this);
}
});
} catch (RejectedExecutionException e) {
// Session is shut down.
}
}
}
fDebugSessionId= sessionId;
if (fServicesTracker != null) {
fServicesTracker.dispose();
}
fServicesTracker = new DsfServicesTracker(DsfUIPlugin.getBundleContext(), sessionId);
if (fViewer != null) {
debugContextChanged();
@ -2397,22 +2400,24 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
}
} else if (fDebugSessionId != null) {
if (getSession() != null) {
// Store the values that we are going to change
final DsfSession session = getSession();
final DsfServicesTracker trackerToDispose= fServicesTracker;
session.getExecutor().execute(new DsfRunnable() {
public void run() {
session.removeServiceEventListener(DisassemblyPart.this);
if (trackerToDispose != null) {
trackerToDispose.dispose();
}
}
});
try {
// Store the values that we are going to change
final DsfSession session = getSession();
session.getExecutor().execute(new DsfRunnable() {
public void run() {
session.removeServiceEventListener(DisassemblyPart.this);
}
});
} catch (RejectedExecutionException e) {
// Session is shut down.
}
}
fDebugSessionId= null;
fTargetContext= null;
fServicesTracker= null;
if (fServicesTracker != null) {
fServicesTracker.dispose();
fServicesTracker= null;
}
if (fViewer != null) {
debugContextChanged();
}
@ -2425,12 +2430,16 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
fUpdatePending = false;
resetViewer();
if (fDebugSessionId != null) {
final DsfSession session= getSession();
session.getExecutor().execute(new DsfRunnable() {
public void run() {
session.addServiceEventListener(DisassemblyPart.this, null);
}
});
try {
final DsfSession session= getSession();
session.getExecutor().execute(new DsfRunnable() {
public void run() {
session.addServiceEventListener(DisassemblyPart.this, null);
}
});
} catch (RejectedExecutionException e) {
// Session is shut down.
}
updatePC(PC_UNKNOWN);

View file

@ -618,11 +618,16 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
fController.removeSteppingControlParticipant(this);
fController = null;
}
fExecutor.execute(new DsfRunnable() { public void run() {
fSession.removeServiceEventListener(DsfSourceDisplayAdapter.this);
fServicesTracker.dispose();
}});
try {
fExecutor.execute(new DsfRunnable() { public void run() {
fSession.removeServiceEventListener(DsfSourceDisplayAdapter.this);
}});
} catch (RejectedExecutionException e) {
// Session is shut down.
}
fServicesTracker.dispose();
fSourceLookup.removeParticipants(new ISourceLookupParticipant[] {fSourceLookupParticipant});
// fSourceLookupParticipant is disposed by the source lookup director