* backend)
*/
public HistoryBuilder(IStateChangeInput stateChangeInput,
- IStateHistoryBackend backend) throws IOException {
+ IStateHistoryBackend backend, boolean buildManually)
+ throws IOException {
if (stateChangeInput == null || backend == null) {
throw new IllegalArgumentException();
}
shs = new StateHistorySystem(hb, true);
sci.assignTargetStateSystem(shs);
- started = false;
+
+ if (buildManually) {
+ TmfSignalManager.deregister(this);
+ this.buildManually();
+ } else {
+ started = false;
+ /* We'll now wait for the signal to start building */
+ }
}
/**
return shs;
}
+ /**
+ * Build the state history without waiting for signals or anything
+ */
+ @SuppressWarnings("unchecked")
+ private void buildManually() {
+ StateSystemBuildRequest request = new StateSystemBuildRequest(this);
+
+ /* Send the request to the trace here, since there is probably no
+ * experiment. */
+ sci.getTrace().sendRequest(request);
+ try {
+ request.waitForCompletion();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
// ------------------------------------------------------------------------
// Signal handlers
* The IStateChangeInput to use for building the history file. It
* may be required even if we are opening an already-existing
* history (ie, for partial histories).
- * @param waitForCompletion
- * Should we block the calling thread until the construction is
- * complete? It has no effect if the file already exists.
+ * @param buildManually
+ * If false, the construction will wait for a signal before
+ * starting. If true, it will build everything right now and
+ * block the caller. It has no effect if the file already exists.
* @return A IStateSystemQuerier handler to the state system, with which you
* can then run queries on the history.
* @throws TmfTraceException
*/
public static IStateSystemQuerier loadStateHistory(File htFile,
- IStateChangeInput htInput, boolean waitForCompletion)
+ IStateChangeInput htInput, boolean buildManually)
throws TmfTraceException {
IStateSystemQuerier ss;
IStateHistoryBackend htBackend;
try {
htBackend = new ThreadedHistoryTreeBackend(htFile,
htInput.getStartTime(), QUEUE_SIZE);
- builder = new HistoryBuilder(htInput, htBackend);
+ builder = new HistoryBuilder(htInput, htBackend, buildManually);
} catch (IOException e) {
/*
* If it fails here however, it means there was a problem writing to