From 6918b6c685627fab139ea76587d922c15228ae6b Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Mon, 16 Dec 2013 15:03:00 -0500 Subject: [PATCH] Bug 353034 - Cache "trace-status" command Change-Id: Id704b2b3824a016c1d9445e8625453944001863b Signed-off-by: Marc Khouzam Reviewed-on: https://git.eclipse.org/r/19876 --- .../dsf/gdb/service/GDBTraceControl_7_2.java | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBTraceControl_7_2.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBTraceControl_7_2.java index 224ddef6138..a9b419a5396 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBTraceControl_7_2.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBTraceControl_7_2.java @@ -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(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); } }