protected void setSubstitutePaths( ISourceLookupDMContext sourceLookupCtx, Map<String, String> entries, RequestMonitor rm) { fCachedEntries = entries; CountingRequestMonitor countingRm = new CountingRequestMonitor(getExecutor(), rm) { @Override protected void handleFailure() { /* * We failed to apply the changes. Clear the cache as it does * not represent the state of the backend. However we don't have * a good recovery here, so on future sourceContainersChanged() * calls we will simply reissue the substitutions. */ fCachedEntries = null; rm.done(); } }; countingRm.setDoneCount(entries.size()); for (Map.Entry<String, String> entry : entries.entrySet()) { fCommand.queueCommand( fCommandFactory.createMISetSubstitutePath( sourceLookupCtx, entry.getKey(), entry.getValue()), new DataRequestMonitor<MIInfo>(getExecutor(), countingRm)); } }
/** * Performs the actual count retrieval and calculation. * * @param rm Request monitor to complete with data. */ private void doGetCount(final DataRequestMonitor<Integer> rm) { // Array to store counts retrieved asynchronously final int[] counts = new int[fDataGenerators.length]; // Counting request monitor is called once all data is retrieved. final CountingRequestMonitor crm = new CountingRequestMonitor(fExecutor, rm) { @Override protected void handleSuccess() { // Pick the highest count value. Arrays.sort(counts, 0, counts.length - 1); int maxCount = counts[counts.length - 1]; rm.setData(maxCount); rm.done(); }; }; // Each call to data generator fills in one value in array. for (int i = 0; i < fDataGenerators.length; i++) { final int finalI = i; fDataGenerators[i].getCount( new DataRequestMonitor<Integer>(ImmediateExecutor.getInstance(), crm) { @Override protected void handleSuccess() { counts[finalI] = getData(); crm.done(); } }); } crm.setDoneCount(fDataGenerators.length); }
/** * Performs the actual value retrieval and calculation. * * @param rm Request monitor to complete with data. */ private void doGetValue(int index, final DataRequestMonitor<Integer> rm) { // Array to store counts retrieved asynchronously final int[] values = new int[fDataGenerators.length]; // Counting request monitor is called once all data is retrieved. final CountingRequestMonitor crm = new CountingRequestMonitor(fExecutor, rm) { @Override protected void handleSuccess() { // Sum up values in array. int sum = 0; for (int value : values) { sum += value; } rm.setData(sum); rm.done(); }; }; // Each call to data generator fills in one value in array. for (int i = 0; i < fDataGenerators.length; i++) { final int finalI = i; fDataGenerators[i].getValue( index, new DataRequestMonitor<Integer>(ImmediateExecutor.getInstance(), crm) { @Override protected void handleSuccess() { values[finalI] = getData(); crm.done(); } }); } crm.setDoneCount(fDataGenerators.length); }
@Override public void sourceContainersChanged( final ISourceLookupDMContext sourceLookupCtx, final DataRequestMonitor<Boolean> rm) { if (!fDirectors.containsKey(sourceLookupCtx)) { rm.setStatus( new Status( IStatus.ERROR, GdbPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_HANDLE, "No source director configured for given context", null)); //$NON-NLS-1$ ); rm.done(); return; } Map<String, String> entries = getSubstitutionsPaths(sourceLookupCtx); if (entries.equals(fCachedEntries)) { rm.done(false); } else { /* * Issue the clear and set commands back to back so that the * executor thread atomically changes the source lookup settings. * Any commands to GDB issued after this call will get the new * source substitute settings. */ CountingRequestMonitor countingRm = new CountingRequestMonitor(getExecutor(), rm) { @Override protected void handleSuccess() { rm.done(true); } }; fCommand.queueCommand( fCommandFactory.createCLIUnsetSubstitutePath(sourceLookupCtx), new DataRequestMonitor<MIInfo>(getExecutor(), countingRm)); initializeSourceSubstitutions(sourceLookupCtx, new RequestMonitor(getExecutor(), countingRm)); countingRm.setDoneCount(2); } }