import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
+import java.util.concurrent.CountDownLatch;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
private final TransientState transState;
private final IStateHistoryBackend backend;
+ /* Latch tracking if the state history is done building or not */
+ private final CountDownLatch finishedLatch = new CountDownLatch(1);
+
/**
* General constructor
*
/* We're opening an existing file */
this.attributeTree = new AttributeTree(this, backend.supplyAttributeTreeReader());
transState.setInactive();
+ finishedLatch.countDown(); /* The history is already built */
+ }
+ }
+
+ @Override
+ public void waitUntilBuilt() {
+ try {
+ finishedLatch.await();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
}
}
*/
attributeTree.writeSelf(attributeTreeFile, attributeTreeFilePos);
}
+ finishedLatch.countDown(); /* Mark the history as finished building */
}
//--------------------------------------------------------------------------
*/
public long getCurrentEndTime();
+ /**
+ * 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
+ * we start doing queries.
+ *
+ * This method blocks the calling thread until the history back-end is done
+ * building. If it's already built (ie, opening a pre-existing file) this
+ * should return immediately. It's an alternative to listening to the
+ * {@link org.eclipse.linuxtools.tmf.core.signal.TmfStateSystemBuildCompleted}
+ * signal.
+ */
+ public void waitUntilBuilt();
+
/**
* Return the current total amount of attributes in the system. This is also
* equal to the quark that will be assigned to the next attribute that's