From: adam Date: Thu, 5 Jul 2007 01:47:42 +0000 (+0000) Subject: remove blocker nonsense from org.ibex.io X-Git-Url: http://git.megacz.com/?p=org.ibex.io.git;a=commitdiff_plain;h=7e42d1f8cb29c10f7b3b3e8679e9f1643c948bda remove blocker nonsense from org.ibex.io darcs-hash:20070705014742-5007d-7f13df49b8d5a9b46d7b6511d06a72f4f205d020.gz --- diff --git a/src/org/ibex/io/Duct.java b/src/org/ibex/io/Duct.java deleted file mode 100644 index e69de29..0000000 diff --git a/src/org/ibex/io/Stream.java b/src/org/ibex/io/Stream.java index d4e0c06..1d03c20 100644 --- a/src/org/ibex/io/Stream.java +++ b/src/org/ibex/io/Stream.java @@ -89,86 +89,51 @@ public class Stream { public static class Closed extends StreamException { public Closed(String s) { super(s); } } - private static Hashtable blocker = new Hashtable(); - public static void kill(Thread thread) { - Stream block = (Stream)blocker.get(thread); - if (block == null) { - Log.warn(Stream.class, "thread " + thread + " is not blocked on a stream"); - } else { - Log.warn(Stream.class, "asynchronously closing " + block); - block.close(); - } - } - public char peekc() { - Stream old = (Stream)blocker.get(Thread.currentThread()); - try { - blocker.put(Thread.currentThread(), this); - flush(); return in.getc(true); - } finally { if (old == null) blocker.remove(Thread.currentThread()); else blocker.put(Thread.currentThread(), old); } + flush(); + return in.getc(true); } public char getc() { - Stream old = (Stream)blocker.get(Thread.currentThread()); - try { - blocker.put(Thread.currentThread(), this); - flush(); char ret = in.getc(false); log(ret); return ret; - } finally { if (old == null) blocker.remove(Thread.currentThread()); else blocker.put(Thread.currentThread(), old); } + flush(); + char ret = in.getc(false); + log(ret); + return ret; } public String readln() { - Stream old = (Stream)blocker.get(Thread.currentThread()); - try { - blocker.put(Thread.currentThread(), this); - flush(); String s = in.readln(); log(s); log('\n'); return s; - } finally { if (old == null) blocker.remove(Thread.currentThread()); else blocker.put(Thread.currentThread(), old); } + flush(); + String s = in.readln(); + log(s); + log('\n'); + return s; } public void print(String s) { - Stream old = (Stream)blocker.get(Thread.currentThread()); - try { - blocker.put(Thread.currentThread(), this); - logWrite(s); - out.write(s); - flush(); - } finally { if (old == null) blocker.remove(Thread.currentThread()); else blocker.put(Thread.currentThread(), old); } + logWrite(s); + out.write(s); + flush(); } public void println(String s) { - Stream old = (Stream)blocker.get(Thread.currentThread()); - try { - blocker.put(Thread.currentThread(), this); - logWrite(s); - logWrite(newLine); - out.write(s); - out.write(newLine); - flush(); - } finally { if (old == null) blocker.remove(Thread.currentThread()); else blocker.put(Thread.currentThread(), old); } + logWrite(s); + logWrite(newLine); + out.write(s); + out.write(newLine); + flush(); } public void flush() { - Stream old = (Stream)blocker.get(Thread.currentThread()); - try { - blocker.put(Thread.currentThread(), this); - if (out != null) try { out.w.flush(); } catch(IOException e) { ioe(e); } - } finally { if (old == null) blocker.remove(Thread.currentThread()); else blocker.put(Thread.currentThread(), old); } + if (out != null) try { out.w.flush(); } catch(IOException e) { ioe(e); } } public int read(byte[] b, int off, int len) { - Stream old = (Stream)blocker.get(Thread.currentThread()); - try { - blocker.put(Thread.currentThread(), this); - flush(); - int ret = in.readBytes(b, off, len); - if (log != null) log("\n[read " + ret + " bytes of binary data ]\n"); - nnl = false; - return ret; - } finally { if (old == null) blocker.remove(Thread.currentThread()); else blocker.put(Thread.currentThread(), old); } + flush(); + int ret = in.readBytes(b, off, len); + if (log != null) log("\n[read " + ret + " bytes of binary data ]\n"); + nnl = false; + return ret; } public int read(char[] c, int off, int len) { - Stream old = (Stream)blocker.get(Thread.currentThread()); - try { - blocker.put(Thread.currentThread(), this); - flush(); - int ret = in.read(c, off, len); - if (log != null && ret != -1) log(new String(c, off, ret)); - return ret; - } finally { if (old == null) blocker.remove(Thread.currentThread()); else blocker.put(Thread.currentThread(), old); } + flush(); + int ret = in.read(c, off, len); + if (log != null && ret != -1) log(new String(c, off, ret)); + return ret; } public void unread(String s) { in.unread(s); }