1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

[291224] Heavy MultiRequestMonitor used where lighter CountingRequestMonitor equally does the job

This commit is contained in:
John Cortell 2009-10-02 20:07:37 +00:00
parent c99f13bd17
commit 0b19264891
3 changed files with 45 additions and 45 deletions

View file

@ -26,7 +26,6 @@ import org.eclipse.cdt.dsf.concurrent.DsfExecutor;
import org.eclipse.cdt.dsf.concurrent.DsfRunnable; import org.eclipse.cdt.dsf.concurrent.DsfRunnable;
import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants; import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants;
import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor; import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor;
import org.eclipse.cdt.dsf.concurrent.MultiRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.RequestMonitor; import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
import org.eclipse.cdt.dsf.datamodel.DMContexts; import org.eclipse.cdt.dsf.datamodel.DMContexts;
import org.eclipse.cdt.dsf.datamodel.IDMContext; import org.eclipse.cdt.dsf.datamodel.IDMContext;
@ -891,36 +890,36 @@ public class VariableVMNode extends AbstractExpressionVMNode
// Create the MultiRequestMonitor to handle completion of the set of getModelData() calls. // Create the MultiRequestMonitor to handle completion of the set of getModelData() calls.
final MultiRequestMonitor<DataRequestMonitor<IVariableDMData>> mrm = final CountingRequestMonitor crm = new CountingRequestMonitor(dsfExecutor, null) {
new MultiRequestMonitor<DataRequestMonitor<IVariableDMData>>(dsfExecutor, null) { @Override
@Override public void handleCompleted() {
public void handleCompleted() { // Now that all the calls to getModelData() are complete, we create an
// Now that all the calls to getModelData() are complete, we create an // IExpressionDMContext object for each local variable name, saving them all
// IExpressionDMContext object for each local variable name, saving them all // in an array.
// in an array.
if (!isSuccess()) { if (!isSuccess()) {
handleFailedUpdate(update); handleFailedUpdate(update);
return; return;
}
IExpressionDMContext[] expressionDMCs = new IExpressionDMContext[localsDMData.size()];
int i = 0;
for (IVariableDMData localDMData : localsDMData) {
expressionDMCs[i++] = expressionService.createExpression(frameDmc, localDMData.getName());
}
// Lastly, we fill the update from the array of view model context objects
// that reference the ExpressionDMC objects for the local variables. This is
// the last code to run for a given call to updateElementsInSessionThread().
// We can now leave anonymous-inner-class hell.
fillUpdateWithVMCs(update, expressionDMCs);
update.done();
} }
IExpressionDMContext[] expressionDMCs = new IExpressionDMContext[localsDMData.size()];
int i = 0;
for (IVariableDMData localDMData : localsDMData) {
expressionDMCs[i++] = expressionService.createExpression(frameDmc, localDMData.getName());
}
// Lastly, we fill the update from the array of view model context objects
// that reference the ExpressionDMC objects for the local variables. This is
// the last code to run for a given call to updateElementsInSessionThread().
// We can now leave anonymous-inner-class hell.
fillUpdateWithVMCs(update, expressionDMCs);
update.done();
}
}; };
int countRM = 0;
// Perform a set of getModelData() calls, one for each local variable's data model // Perform a set of getModelData() calls, one for each local variable's data model
// context object. In the handleCompleted() method of the DataRequestMonitor, add the // context object. In the handleCompleted() method of the DataRequestMonitor, add the
@ -932,14 +931,14 @@ public class VariableVMNode extends AbstractExpressionVMNode
@Override @Override
public void handleCompleted() { public void handleCompleted() {
localsDMData.add(getData()); localsDMData.add(getData());
mrm.requestMonitorDone(this); crm.done();
} }
}; };
mrm.add(rm);
stackFrameService.getVariableData(localDMC, rm); stackFrameService.getVariableData(localDMC, rm);
countRM++;
} }
crm.setDoneCount(countRM);
} }
}; };

View file

@ -19,7 +19,6 @@ import org.eclipse.cdt.dsf.concurrent.ConfinedToDsfExecutor;
import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor; import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.MultiRequestMonitor; import org.eclipse.cdt.dsf.concurrent.MultiRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
import org.eclipse.cdt.dsf.ui.concurrent.ViewerCountingRequestMonitor; import org.eclipse.cdt.dsf.ui.concurrent.ViewerCountingRequestMonitor;
import org.eclipse.cdt.dsf.ui.concurrent.ViewerDataRequestMonitor; import org.eclipse.cdt.dsf.ui.concurrent.ViewerDataRequestMonitor;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenCountUpdate; import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenCountUpdate;
@ -261,30 +260,32 @@ public class DefaultVMContentProviderStrategy implements IElementContentProvider
// Get the mapping of all the counts. // Get the mapping of all the counts.
final Integer[] counts = new Integer[childNodes.length]; final Integer[] counts = new Integer[childNodes.length];
final MultiRequestMonitor<RequestMonitor> childrenCountMultiReqMon = new MultiRequestMonitor<RequestMonitor>( final CountingRequestMonitor crm = new CountingRequestMonitor(getVMProvider().getExecutor(), rm) {
getVMProvider().getExecutor(), rm) {
@Override @Override
protected void handleSuccess() { protected void handleSuccess() {
rm.setData(counts); rm.setData(counts);
rm.done(); rm.done();
} }
}; };
int countRM = 0;
for (int i = 0; i < childNodes.length; i++) { for (int i = 0; i < childNodes.length; i++) {
final int nodeIndex = i; final int nodeIndex = i;
getVMProvider().updateNode( getVMProvider().updateNode(
childNodes[i], childNodes[i],
new VMChildrenCountUpdate(update, childrenCountMultiReqMon.add(new ViewerDataRequestMonitor<Integer>( new VMChildrenCountUpdate(update, new ViewerDataRequestMonitor<Integer>(
getVMProvider().getExecutor(), update) { getVMProvider().getExecutor(), update) {
@Override @Override
protected void handleCompleted() { protected void handleCompleted() {
if (isSuccess()) { if (isSuccess()) {
counts[nodeIndex] = getData(); counts[nodeIndex] = getData();
} }
childrenCountMultiReqMon.requestMonitorDone(this); crm.done();
} }
}))); }));
countRM++;
} }
crm.setDoneCount(countRM);
} }
/** /**

View file

@ -20,7 +20,6 @@ import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.DsfRunnable; import org.eclipse.cdt.dsf.concurrent.DsfRunnable;
import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants; import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants;
import org.eclipse.cdt.dsf.concurrent.MultiRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.RequestMonitor; import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
import org.eclipse.core.runtime.ISafeRunnable; import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.ListenerList; import org.eclipse.core.runtime.ListenerList;
@ -645,8 +644,7 @@ public class DefaultVMModelProxyStrategy implements IVMModelProxy {
if (calculdateOffsets) { if (calculdateOffsets) {
final Integer[] counts = new Integer[childNodes.length]; final Integer[] counts = new Integer[childNodes.length];
final MultiRequestMonitor<RequestMonitor> childrenCountMultiRequestMon = final CountingRequestMonitor crm = new CountingRequestMonitor(getVMProvider().getExecutor(), rm) {
new MultiRequestMonitor<RequestMonitor>(getVMProvider().getExecutor(), rm) {
@Override @Override
protected void handleSuccess() { protected void handleSuccess() {
Map<IVMNode, Integer> data = new HashMap<IVMNode, Integer>(); Map<IVMNode, Integer> data = new HashMap<IVMNode, Integer>();
@ -660,7 +658,8 @@ public class DefaultVMModelProxyStrategy implements IVMModelProxy {
rm.setData(data); rm.setData(data);
rm.done(); rm.done();
} }
}; };
int countRM = 0;
for (int i = 0; i < childNodes.length; i++) { for (int i = 0; i < childNodes.length; i++) {
final int nodeIndex = i; final int nodeIndex = i;
@ -668,17 +667,18 @@ public class DefaultVMModelProxyStrategy implements IVMModelProxy {
childNodes[i], childNodes[i],
new VMChildrenCountUpdate( new VMChildrenCountUpdate(
delta, getVMProvider().getPresentationContext(), delta, getVMProvider().getPresentationContext(),
childrenCountMultiRequestMon.add( new DataRequestMonitor<Integer>(getVMProvider().getExecutor(), crm) {
new DataRequestMonitor<Integer>(getVMProvider().getExecutor(), rm) {
@Override @Override
protected void handleCompleted() { protected void handleCompleted() {
counts[nodeIndex] = getData(); counts[nodeIndex] = getData();
childrenCountMultiRequestMon.requestMonitorDone(this); crm.done();
} }
}) }
) )
); );
countRM++;
} }
crm.setDoneCount(countRM);
} else { } else {
Map<IVMNode, Integer> data = new HashMap<IVMNode, Integer>(); Map<IVMNode, Integer> data = new HashMap<IVMNode, Integer>();
for (int i = 0; i < childNodes.length; i++) { for (int i = 0; i < childNodes.length; i++) {