Mercurial > 510Connectbot
diff src/org/tn5250j/framework/tn5250/tnvt.java @ 99:eda03b809f48
move blocking test from socket read to queue take
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Tue, 17 Jun 2014 15:13:41 -0700 |
parents | 33eb63352be5 |
children | 9204fe526e65 |
line wrap: on
line diff
--- a/src/org/tn5250j/framework/tn5250/tnvt.java Tue Jun 17 11:35:01 2014 -0700 +++ b/src/org/tn5250j/framework/tn5250/tnvt.java Tue Jun 17 15:13:41 2014 -0700 @@ -77,7 +77,7 @@ import java.util.Properties; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; - +import java.util.concurrent.TimeUnit; import javax.net.ssl.SSLSocket; import android.content.Intent; @@ -140,6 +140,7 @@ private boolean cursorOn = false; private String hostname = ""; private int port = 23; + private vt320 buffer; private boolean connected = false; private boolean support132 = true; private ByteArrayOutputStream baosp = null; @@ -260,6 +261,7 @@ try { this.hostname = hostname; this.port = port; + this.buffer = buffer; try { screen52.getOIA().setInputInhibited(ScreenOIA.INPUTINHIBITED_SYSTEM_WAIT, @@ -298,7 +300,7 @@ } - producer = new DataStreamProducer(this, bin, buffer, dsq, abyte0); + producer = new DataStreamProducer(this, bin, dsq, abyte0); pthread = new Thread(producer); // pthread.setPriority(pthread.MIN_PRIORITY); pthread.setPriority(Thread.NORM_PRIORITY); @@ -986,7 +988,12 @@ while (keepTrucking) { try { - bk.initialize((byte[]) dsq.take()); + Object e = dsq.poll(0L, TimeUnit.SECONDS); + if (e == null) { + buffer.testChanged(); + e = dsq.take(); + }; + bk.initialize((byte[])e); } catch (InterruptedException ie) { Log.w(TAG," vt thread interrupted and stopping "); keepTrucking = false;