1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 08:55:25 +02:00

Bug 353034 - Cache "trace-status" command

Change-Id: Id704b2b3824a016c1d9445e8625453944001863b
Signed-off-by: Marc Khouzam <marc.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/19876
This commit is contained in:
Marc Khouzam 2013-12-16 15:03:00 -05:00
parent 99bc05cba7
commit 6918b6c685

View file

@ -11,6 +11,7 @@
package org.eclipse.cdt.dsf.gdb.service;
import java.util.Hashtable;
import java.util.concurrent.TimeUnit;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.ImmediateRequestMonitor;
@ -389,7 +390,7 @@ public class GDBTraceControl_7_2 extends AbstractDsfService implements IGDBTrace
}
}
private CommandCache fTraceCache;
private CommandCache fTraceStatusCache;
private ICommandControlService fConnection;
private CommandFactory fCommandFactory;
private IGDBBackend fBackend;
@ -437,8 +438,8 @@ public class GDBTraceControl_7_2 extends AbstractDsfService implements IGDBTrace
fConnection = getServicesTracker().getService(ICommandControlService.class);
fTraceCache = new CommandCache(getSession(), fConnection);
fTraceCache.setContextAvailable(fConnection.getContext(), true);
fTraceStatusCache = new CommandCache(getSession(), fConnection);
fTraceStatusCache.setContextAvailable(fConnection.getContext(), true);
fBackend = getServicesTracker().getService(IGDBBackend.class);
fCommandFactory = getServicesTracker().getService(IMICommandControl.class).getCommandFactory();
@ -753,7 +754,22 @@ public class GDBTraceControl_7_2 extends AbstractDsfService implements IGDBTrace
return;
}
fConnection.queueCommand(
// Start an automatic one-time flushing of the TraceStatusCache.
// This avoids sending -trace-status multiples time in a very short
// amount of time. We still have to clear the cache very quickly
// because -trace-status can change very fast as it reports
// the number of frames collected. Having a small interval of
// stale data is currently not a big deal, and not user-visible.
// We just have to be careful in the future that command enablement
// should not be affected by this cache. For example, if a command
// checks if it should be enabled by using this call, and misses
// the latest state due to the cache.
// Bug 353034
getExecutor().schedule(new Runnable() {
@Override public void run() { fTraceStatusCache.reset(context); }
}, 300, TimeUnit.MILLISECONDS);
fTraceStatusCache.execute(
fCommandFactory.createMITraceStatus(context),
new DataRequestMonitor<MITraceStatusInfo>(getExecutor(), rm) {
@Override
@ -1120,6 +1136,6 @@ public class GDBTraceControl_7_2 extends AbstractDsfService implements IGDBTrace
@Override
public void flushCache(IDMContext context) {
fTraceCache.reset(context);
fTraceStatusCache.reset(context);
}
}