ArrayList<ControlFlowEntry> entryList = new ArrayList<>();
LttngKernelTrace ctfKernelTrace = (LttngKernelTrace) aTrace;
ITmfStateSystem ssq = ctfKernelTrace.getStateSystems().get(LttngKernelTrace.STATE_ID);
- if (!ssq.waitUntilBuilt()) {
+ if (ssq == null) {
+ return;
+ }
+ ssq.waitUntilBuilt();
+ if (ssq.isCancelled()) {
return;
}
long start = ssq.getStartTime();
if (aTrace instanceof LttngKernelTrace) {
LttngKernelTrace lttngKernelTrace = (LttngKernelTrace) aTrace;
ITmfStateSystem ssq = lttngKernelTrace.getStateSystems().get(LttngKernelTrace.STATE_ID);
- if (!ssq.waitUntilBuilt()) {
+ if (ssq == null) {
+ return;
+ }
+ ssq.waitUntilBuilt();
+ if (ssq.isCancelled()) {
return;
}
long startTime = ssq.getStartTime();
}
@Override
- public boolean waitUntilBuilt() {
+ public boolean isCancelled() {
+ return buildCancelled;
+ }
+
+ @Override
+ public void waitUntilBuilt() {
try {
finishedLatch.await();
} catch (InterruptedException e) {
e.printStackTrace();
}
- return !buildCancelled;
}
@Override
*/
long getCurrentEndTime();
+ /**
+ * Check if the construction of this state system was cancelled or not. If
+ * false is returned, it can mean that the building was finished
+ * successfully, or that it is still ongoing. You can check independently
+ * with {@link #waitUntilBuilt()} if it is finished or not.
+ *
+ * @return If the construction was cancelled or not. In true is returned, no
+ * queries should be run afterwards.
+ * @since 3.0
+ */
+ boolean isCancelled();
+
/**
* While it's possible to query a state history that is being built,
* sometimes we might want to wait until the construction is finished before
* building. If it's already built (ie, opening a pre-existing file) this
* should return immediately.
*
- * @return If the build was successful. If false is returned, this either
- * means there was a problem during the build, or it got cancelled
- * before it could finished. In that case, no queries should be run
- * afterwards.
+ * You should always check with {@link #isCancelled()} if it is safe to
+ * query this state system before doing queries.
+ *
+ * @since 3.0
*/
- boolean waitUntilBuilt();
+ void waitUntilBuilt();
/**
* Notify the state system that the trace is being closed, so it should
final List<Long> list = new LinkedList<>();
final long increment = (end - start) / nb;
- if (!totalsStats.waitUntilBuilt()) {
+ totalsStats.waitUntilBuilt();
+ if (totalsStats.isCancelled()) {
return list;
}
* @return If both state systems were built successfully
*/
private boolean waitUntilBuilt() {
- boolean check1 = totalsStats.waitUntilBuilt();
- boolean check2 = typesStats.waitUntilBuilt();
+ totalsStats.waitUntilBuilt();
+ typesStats.waitUntilBuilt();
+ boolean check1 = !totalsStats.isCancelled();
+ boolean check2 = !typesStats.isCancelled();
return (check1 && check2);
}
long resolution = Math.max(1, (fZoomEndTime - fZoomStartTime) / fDisplayWidth);
for (ThreadEntry threadEntry : fZoomEntryList) {
ITmfStateSystem ss = threadEntry.fThreadTrace.getStateSystems().get(CallStackStateProvider.ID);
- if (ss == null || !ss.waitUntilBuilt()) {
+ if (ss == null) {
+ continue;
+ }
+ ss.waitUntilBuilt();
+ if (ss.isCancelled()) {
continue;
}
for (ITimeGraphEntry child : threadEntry.getChildren()) {
return;
}
ITmfStateSystem ss = aTrace.getStateSystems().get(CallStackStateProvider.ID);
- if (ss == null || !ss.waitUntilBuilt()) {
- String threadName = Messages.CallStackView_StackInfoNotAvailable + ' ' + '(' + aTrace.getName() + ')';
- ThreadEntry threadEntry = new ThreadEntry(aTrace, threadName, -1, 0, 0);
- entryList.add(threadEntry);
+ if (ss == null) {
+ addUnavailableEntry(aTrace, entryList);
+ continue;
+ }
+ ss.waitUntilBuilt();
+ if (ss.isCancelled()) {
+ addUnavailableEntry(aTrace, entryList);
continue;
}
long startTime = ss.getStartTime();
}
}
+ private void addUnavailableEntry(ITmfTrace trace, List<ThreadEntry> list) {
+ String threadName = Messages.CallStackView_StackInfoNotAvailable + ' ' + '(' + trace.getName() + ')';
+ ThreadEntry threadEntry = new ThreadEntry(trace, threadName, -1, 0, 0);
+ list.add(threadEntry);
+ }
+
private void buildStatusEvents(ITmfTrace trace, CallStackEntry entry, IProgressMonitor monitor) {
ITmfStateSystem ss = entry.getTrace().getStateSystems().get(CallStackStateProvider.ID);
long start = ss.getStartTime();
}
for (ThreadEntry threadEntry : fEntryList) {
ITmfStateSystem ss = threadEntry.fThreadTrace.getStateSystems().get(CallStackStateProvider.ID);
- if (ss == null || !ss.waitUntilBuilt()) {
+ if (ss == null) {
+ continue;
+ }
+ ss.waitUntilBuilt();
+ if (ss.isCancelled()) {
continue;
}
long queryTime = Math.max(ss.getStartTime(), Math.min(ss.getCurrentEndTime(), time));