views.
TRACE_COLUMN\r
};\r
\r
+ /**\r
+ * Redraw state enum\r
+ */\r
+ private enum State { IDLE, BUSY, PENDING };\r
+\r
// ------------------------------------------------------------------------\r
// Fields\r
// ------------------------------------------------------------------------\r
// A comparator class\r
private final ControlFlowEntryComparator fControlFlowEntryComparator = new ControlFlowEntryComparator();\r
\r
+ // The redraw state used to prevent unnecessary queuing of display runnables\r
+ private State fRedrawState = State.IDLE;\r
+\r
+ // The redraw synchronization object\r
+ final private Object fSyncObj = new Object();\r
+\r
// ------------------------------------------------------------------------\r
// Classes\r
// ------------------------------------------------------------------------\r
}\r
zoom(entry, fMonitor);\r
}\r
- redraw();\r
}\r
\r
private void zoom(ControlFlowEntry entry, IProgressMonitor monitor) {\r
entry.setZoomedEventList(zoomedEventList);\r
}\r
}\r
+ redraw();\r
for (ControlFlowEntry child : entry.getChildren()) {\r
if (fMonitor.isCanceled()) {\r
return;\r
List<ITimeEvent> eventList = null;\r
try {\r
int statusQuark = ssq.getQuarkRelative(entry.getThreadQuark(), Attributes.STATUS);\r
- List<ITmfStateInterval> statusIntervals = ssq.queryHistoryRange(statusQuark, startTime, endTime - 1, resolution);\r
+ List<ITmfStateInterval> statusIntervals = ssq.queryHistoryRange(statusQuark, startTime, endTime - 1, resolution, monitor);\r
eventList = new ArrayList<ITimeEvent>(statusIntervals.size());\r
long lastEndTime = -1;\r
for (ITmfStateInterval statusInterval : statusIntervals) {\r
}\r
\r
private void redraw() {\r
+ synchronized (fSyncObj) {\r
+ if (fRedrawState == State.IDLE) {\r
+ fRedrawState = State.BUSY;\r
+ } else {\r
+ fRedrawState = State.PENDING;\r
+ return;\r
+ }\r
+ }\r
Display.getDefault().asyncExec(new Runnable() {\r
@Override\r
public void run() {\r
}\r
fTimeGraphCombo.redraw();\r
fTimeGraphCombo.update();\r
+ synchronized (fSyncObj) {\r
+ if (fRedrawState == State.PENDING) {\r
+ fRedrawState = State.IDLE;\r
+ redraw();\r
+ } else {\r
+ fRedrawState = State.IDLE;\r
+ }\r
+ }\r
}\r
});\r
}\r
/** Initial time range */\r
private static final long INITIAL_WINDOW_OFFSET = (1L * 100 * 1000 * 1000); // .1sec\r
\r
+ /**\r
+ * Redraw state enum\r
+ */\r
+ private enum State { IDLE, BUSY, PENDING };\r
+\r
// ------------------------------------------------------------------------\r
// Fields\r
// ------------------------------------------------------------------------\r
// The zoom thread\r
private ZoomThread fZoomThread;\r
\r
+ // The redraw state used to prevent unnecessary queuing of display runnables\r
+ private State fRedrawState = State.IDLE;\r
+\r
+ // The redraw synchronization object\r
+ final private Object fSyncObj = new Object();\r
+\r
// ------------------------------------------------------------------------\r
// Classes\r
// ------------------------------------------------------------------------\r
entry.setZoomedEventList(zoomedEventList);\r
}\r
}\r
+ redraw();\r
}\r
}\r
- redraw();\r
}\r
\r
public void cancel() {\r
try {\r
if (entry.getType().equals(Type.CPU)) {\r
int statusQuark = ssq.getQuarkRelative(quark, Attributes.STATUS);\r
- List<ITmfStateInterval> statusIntervals = ssq.queryHistoryRange(statusQuark, startTime, endTime - 1, resolution);\r
+ List<ITmfStateInterval> statusIntervals = ssq.queryHistoryRange(statusQuark, startTime, endTime - 1, resolution, monitor);\r
eventList = new ArrayList<ITimeEvent>(statusIntervals.size());\r
long lastEndTime = -1;\r
for (ITmfStateInterval statusInterval : statusIntervals) {\r
}\r
}\r
} else if (entry.getType().equals(Type.IRQ)) {\r
- List<ITmfStateInterval> irqIntervals = ssq.queryHistoryRange(quark, startTime, endTime - 1, resolution);\r
+ List<ITmfStateInterval> irqIntervals = ssq.queryHistoryRange(quark, startTime, endTime - 1, resolution, monitor);\r
eventList = new ArrayList<ITimeEvent>(irqIntervals.size());\r
long lastEndTime = -1;\r
boolean lastIsNull = true;\r
lastEndTime = time + duration;\r
}\r
} else if (entry.getType().equals(Type.SOFT_IRQ)) {\r
- List<ITmfStateInterval> softIrqIntervals = ssq.queryHistoryRange(quark, startTime, endTime - 1, resolution);\r
+ List<ITmfStateInterval> softIrqIntervals = ssq.queryHistoryRange(quark, startTime, endTime - 1, resolution, monitor);\r
eventList = new ArrayList<ITimeEvent>(softIrqIntervals.size());\r
long lastEndTime = -1;\r
boolean lastIsNull = true;\r
\r
\r
private void redraw() {\r
+ synchronized (fSyncObj) {\r
+ if (fRedrawState == State.IDLE) {\r
+ fRedrawState = State.BUSY;\r
+ } else {\r
+ fRedrawState = State.PENDING;\r
+ return;\r
+ }\r
+ }\r
Display.getDefault().asyncExec(new Runnable() {\r
@Override\r
public void run() {\r
}\r
fTimeGraphViewer.getControl().redraw();\r
fTimeGraphViewer.getControl().update();\r
+ synchronized (fSyncObj) {\r
+ if (fRedrawState == State.PENDING) {\r
+ fRedrawState = State.IDLE;\r
+ redraw();\r
+ } else {\r
+ fRedrawState = State.IDLE;\r
+ }\r
+ }\r
}\r
});\r
}\r
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.linuxtools.internal.tmf.core.Tracer;
import org.eclipse.linuxtools.tmf.core.exceptions.AttributeNotFoundException;
import org.eclipse.linuxtools.tmf.core.exceptions.TimeRangeException;
public List<ITmfStateInterval> queryHistoryRange(int attributeQuark,
long t1, long t2, long resolution) throws TimeRangeException,
AttributeNotFoundException {
+ return queryHistoryRange(attributeQuark, t1, t2, resolution, new NullProgressMonitor());
+ }
+
+ @Override
+ public List<ITmfStateInterval> queryHistoryRange(int attributeQuark,
+ long t1, long t2, long resolution, IProgressMonitor monitor) throws TimeRangeException,
+ AttributeNotFoundException {
List<ITmfStateInterval> intervals;
ITmfStateInterval currentInterval;
long ts, tEnd;
*/
for (ts = t1; (currentInterval.getEndTime() != -1) && (ts < tEnd);
ts += resolution) {
+ if (monitor.isCanceled()) {
+ return intervals;
+ }
if (ts <= currentInterval.getEndTime()) {
continue;
}
import java.util.List;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.linuxtools.tmf.core.exceptions.AttributeNotFoundException;
import org.eclipse.linuxtools.tmf.core.exceptions.TimeRangeException;
import org.eclipse.linuxtools.tmf.core.interval.ITmfStateInterval;
public List<ITmfStateInterval> queryHistoryRange(int attributeQuark,
long t1, long t2, long resolution) throws TimeRangeException,
AttributeNotFoundException;
+
+ /**
+ * Return the state history of a given attribute, but with at most one
+ * update per "resolution". This can be useful for populating views (where
+ * it's useless to have more than one query per pixel, for example).
+ * A progress monitor can be used to cancel the query before completion.
+ *
+ * @param attributeQuark
+ * Which attribute this query is interested in
+ * @param t1
+ * Start time of the range query
+ * @param t2
+ * Target end time of the query. If t2 is greater than the end of
+ * the trace, we will return what we have up to the end of the
+ * history.
+ * @param resolution
+ * The "step" of this query
+ * @param monitor
+ * A progress monitor. If the monitor is canceled during a query,
+ * we will return what has been found up to that point.
+ * @return The List of states that happened between t1 and t2
+ * @throws TimeRangeException
+ * If t1 is invalid, if t2 <= t1, or if the resolution isn't
+ * greater than zero.
+ * @throws AttributeNotFoundException
+ * If the attribute doesn't exist
+ * @since 1.1
+ */
+ public List<ITmfStateInterval> queryHistoryRange(int attributeQuark,
+ long t1, long t2, long resolution, IProgressMonitor monitor) throws TimeRangeException,
+ AttributeNotFoundException;
}