⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 debuggerwriter.java

📁 Python Development Environment (Python IDE plugin for Eclipse). Features editor, code completion, re
💻 JAVA
字号:
package org.python.pydev.debug.model.remote;

import java.io.IOException;
import java.io.OutputStreamWriter;
import java.net.Socket;
import java.util.ArrayList;

/**
 * Writer writes debugger commands to the network. Use postCommand to put new
 * ones in queue.
 */
public class DebuggerWriter implements Runnable {

    /**
     * connection socket
     */
    private Socket socket;

    /**
     * a list of RemoteDebuggerCommands
     */
    private ArrayList cmdQueue = new ArrayList();

    private OutputStreamWriter out;

    private boolean done = false;

    public DebuggerWriter(Socket s) throws IOException {
        socket = s;
        out = new OutputStreamWriter(s.getOutputStream());
    }

    /**
     * Add command for processing
     */
    public void postCommand(AbstractDebuggerCommand cmd) {
        synchronized (cmdQueue) {
            cmdQueue.add(cmd);
        }
    }

    public void done() {
        this.done = true;
    }

    /**
     * Loops and writes commands to the output
     */
    public void run() {
        while (!done) {
            AbstractDebuggerCommand cmd = null;
            synchronized (cmdQueue) {
                if (cmdQueue.size() > 0)
                    cmd = (AbstractDebuggerCommand) cmdQueue.remove(0);
            }
            try {
                if (cmd != null) {
                    cmd.aboutToSend();
                    out.write(cmd.getOutgoing());
                    out.write("\n");
                    out.flush();
                }
                synchronized (this) {
                    Thread.sleep(100);
                }
            } catch (InterruptedException e) {
                done = true;
            } catch (IOException e1) {
                done = true;
            }
            if ((socket == null) || !socket.isConnected()) {
                done = true;
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -