EDU.oswego.cs.dl.util.concurrent.misc
public class: PipedChannel [javadoc |
source]
java.lang.Object
EDU.oswego.cs.dl.util.concurrent.SemaphoreControlledChannel
EDU.oswego.cs.dl.util.concurrent.misc.PipedChannel
All Implemented Interfaces:
BoundedChannel
A channel based on a java.io.PipedInputStream and
java.io.PipedOutputStream. Elements are serialized
using ObjectInputStreams and ObjectOutputStreams
upon insertion and extraction from the pipe.
IO Exceptions are transformed into Errors. This is
in general not a good idea, but seems to be the most
reasonable compromise for the intended usage contexts.
Status Uncertain. There are enough
conceptual and implementation snags surrounding use
of pipes as Channels to downplay use. However,
without such bridges, people would have to
duplicate code that should work the same way in both cases.
[ Introduction to this package. ]
Field Summary |
---|
protected ObjectInputStream | in_ | |
protected ObjectOutputStream | out_ | |
protected final PipedOutputStream | outp_ | |
protected final PipedInputStream | inp_ | |
Methods from java.lang.Object: |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method from EDU.oswego.cs.dl.util.concurrent.misc.PipedChannel Detail: |
protected Object extract() {
try {
return in().readObject();
}
catch (InterruptedIOException ex) {
Thread.currentThread().interrupt();
return null;
}
catch (IOException ex) {
ex.printStackTrace();
throw new Error("IO exception during take");
}
catch (ClassNotFoundException ex) {
ex.printStackTrace();
throw new Error("Serialization exception during take");
}
}
Shared mechanics for take-based methods |
protected synchronized ObjectInputStream in() {
try {
if (in_ == null) in_ = new ObjectInputStream(inp_);
return in_;
}
catch (IOException ex) {
ex.printStackTrace();
throw new Error("IO exception during open");
}
}
Return input stream, first constructing if necessary.
Needed because Object streams can block on open. |
protected void insert(Object x) {
try {
out().writeObject(x);
}
catch (InterruptedIOException ex) {
Thread.currentThread().interrupt();
}
catch (IOException ex) {
ex.printStackTrace();
throw new Error("IO exception during put");
}
}
Shared mechanics for put-based methods |
protected synchronized ObjectOutputStream out() {
try {
if (out_ == null) out_ = new ObjectOutputStream(outp_);
return out_;
}
catch (IOException ex) {
ex.printStackTrace();
throw new Error("IO exception during open");
}
}
Return output stream, first constructing if necessary.
Needed because Object streams can block on open. |
public Object peek() {
return null;
}
|