# HG changeset patch # User Carl Byington # Date 1430506351 25200 # Node ID 2586a4f5c8c30d6dba7f642c85523036e63f76db # Parent adc776858a2dd5ded60281b3c011dd5cf25a7640 add mechanism to allow getfield from other threads diff -r adc776858a2d -r 2586a4f5c8c3 AndroidManifest.xml --- a/AndroidManifest.xml Tue Jul 08 09:29:08 2014 -0700 +++ b/AndroidManifest.xml Fri May 01 11:52:31 2015 -0700 @@ -2,7 +2,7 @@ + android:versionName="1.0.4-0" > clients = new ConcurrentHashMap(); public static int currentConnection = -1; @@ -100,6 +104,16 @@ if (handler != null) handler.sendMessage(handler.obtainMessage(MonitorActivity.MESSAGE_CODE_PRINT, msg)); } + public synchronized void setCurrentConnection(int connection) { + currentConnection = connection; + } + + public synchronized int nextConnection() { + int c = 1; + while (clients.get(c) != null) c++; + return c; + } + @Override public int onStartCommand(Intent intent, int flags, int startId) { Log.i(TAG, "service onStartCommand()"); @@ -110,6 +124,7 @@ public void onDestroy() { try { Log.i(TAG, "service onDestroy()"); + teCloseAll(); talker.stop(); talker.shutdown(); wifiLock.release(); @@ -134,7 +149,7 @@ while (true) { try{ socket = serverSocket.accept(); - connection = connection + 1; + connection = nextConnection(); CommunicationThread commThread = new CommunicationThread(connection, socket); clients.put(connection, commThread); commThread.start(); @@ -157,12 +172,16 @@ } class CommunicationThread extends Thread { + public int thread_id; public int connection; + private String initString = null; private Socket client_socket; private InputStream client_in; private OutputStream client_out; private boolean is_closing = false; - private BlockingQueue queue = new ArrayBlockingQueue(1); + private Integer getfields_outstanding = 0; + private BlockingQueue value_queue = new ArrayBlockingQueue(1); + private BlockingQueue packet_queue = new ArrayBlockingQueue(10000); public CommunicationThread(int handle, Socket socket) { connection = handle; @@ -175,6 +194,10 @@ } } + public synchronized void abandon() { + value_queue.offer(new triple(0, 0, new char[0])); + } + public void speak(byte [] msg, boolean flush, boolean synchronous) { if (speech) { String smsg = bytesToString(msg); @@ -226,6 +249,24 @@ return b; } + void cleanup(char[] buf) { + int i; + for (i=0; i CURSORMOVE = 3 (TE -> Monitor). - The first argument is the line number (0..23) - and the second argument is the column number (0..79). + The first argument is the line number (0..23), + the second argument is the column number (0..79), and the third + argument is the reason for sending this cursor update. REASON=0 is + from a previous CURSORREQUEST command. REASON=1 is a cursor update + related to the previous SCREENCHANGE buffer update. REASON=2 is + a cursor update caused by user keystrokes.