return runThread.getError() == null;
}
private boolean command_resumeCurrentThread(boolean shouldStepThread) {
ExecutionContextImpl ec = getExecutionContext();
// If we're not suspended we can't resume.
if (!ec.hasSuspendedThreads()) {
iceLogger.log(Level.INFO, "There is no CAL program currently suspended.");
return true;
}
final Set<Thread> suspendedThreads = ec.getThreadSuspensions().keySet();
final Thread currentSuspendedThread = getDebugController().getCurrentSuspendedThread();
if (!suspendedThreads.contains(currentSuspendedThread)) {
iceLogger.log(Level.INFO, "The current thread is no longer suspended. Change to another thread.");
return true;
}
if (shouldStepThread) {
ec.addThreadToBeStepped(currentSuspendedThread);
} else {
ec.removeThreadToBeStepped(currentSuspendedThread);
}
iceLogger.log(Level.INFO, "Resuming execution of: " + lastCode + " on thread: " + currentSuspendedThread.getName());
// Start an interrupt monitor. This checks the input stream and sets
// the runThread halt flag if any input is detected while the CAL
// program is executing.
InterruptMonitor im = new InterruptMonitor (runThread);
im.start();
// Figure out whether we should block, or switch to another thread as the current suspended thread
suspendedThreads.remove(currentSuspendedThread);
// Tell the execution context that it is time to resume.
if (suspendedThreads.isEmpty()) {
getDebugController().setShouldBlockUI(true);
ec.resumeThread(currentSuspendedThread);
getDebugController().blockUntilCompletionOrInterruption();
} else if (shouldStepThread) {
// since we are stepping, we would like to block the UI until the next interruption (hopefully it's the thread being stepped)
getDebugController().setShouldBlockUI(true);
ec.resumeThread(currentSuspendedThread);
getDebugController().blockUntilCompletionOrInterruption();
} else {
ec.resumeThread(currentSuspendedThread);
// if the thread is getting resumed without stepping, choose another current thread
getDebugController().setCurrentSuspendedThread(suspendedThreads.iterator().next());
}
// Shut down the interrupt monitor.