Package org.openquark.cal.internal.runtime

Examples of org.openquark.cal.internal.runtime.ExecutionContextImpl$SuspensionState


       
        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.
View Full Code Here


   
    /**
     * Shows the currently suspended threads.
     */
    private void command_showSuspendedThreads() {
        ExecutionContextImpl ec = getExecutionContext();
       
        Map<Thread, SuspensionState> suspensions = ec.getThreadSuspensions();
       
        SortedMap<Long, Thread> threads = new TreeMap<Long, Thread>();
        for (final Thread thread : suspensions.keySet()) {
            threads.put(Long.valueOf(thread.getId()), thread);
        }
View Full Code Here

        } catch (NumberFormatException e) {
            iceLogger.log(Level.INFO, "Invalid thread ID: " + arg);
            return;
        }
       
        ExecutionContextImpl ec = getExecutionContext();
       
        Map<Thread, SuspensionState> suspensions = ec.getThreadSuspensions();
       
        Thread match = null;
        for (final Thread thread : suspensions.keySet()) {
            if (thread.getId() == threadID) {
                match = thread;
View Full Code Here

       
        // We want to preserve the settings in the execution context
        // which relate to tracing and breakpoints.
       
        // Get the current execution context.
        ExecutionContextImpl oldExecutionContext = getExecutionContext();
       
        // Discard the FunctionRunThread.  This holds the executor, execution
        // context, etc.
        runThread  = null;
       
        // Get a new execution context.
        ExecutionContextImpl newExecutionContext = getExecutionContext();
       
        // Update the new execution context with settings from the old one.
        newExecutionContext.setBreakpoints(oldExecutionContext.getBreakpoints());      
       
        newExecutionContext.setTracedFunctions(oldExecutionContext.getTracedFunctions());       
       
        newExecutionContext.setTracingEnabled(oldExecutionContext.isTracingEnabled());
        newExecutionContext.setTraceShowsFunctionArgs(oldExecutionContext.traceShowsFunctionArgs());
        newExecutionContext.setTraceShowsThreadName(oldExecutionContext.traceShowsThreadName());
    }
View Full Code Here

TOP

Related Classes of org.openquark.cal.internal.runtime.ExecutionContextImpl$SuspensionState

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.