EDU.oswego.cs.dl.util.concurrent.misc

Class PipedChannel

Implemented Interfaces:
BoundedChannel, Channel, Puttable, Takable

public class PipedChannel
extends SemaphoreControlledChannel

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 PipedInputStream
inp_
protected ObjectOutputStream
out_
protected PipedOutputStream
outp_

Fields inherited from class EDU.oswego.cs.dl.util.concurrent.SemaphoreControlledChannel

capacity_, putGuard_, takeGuard_

Constructor Summary

PipedChannel()

Method Summary

protected Object
extract()
Shared mechanics for take-based methods *
protected ObjectInputStream
in()
Return input stream, first constructing if necessary.
protected void
insert(Object x)
Shared mechanics for put-based methods *
protected ObjectOutputStream
out()
Return output stream, first constructing if necessary.
Object
peek()
Stubbed out for now *

Methods inherited from class EDU.oswego.cs.dl.util.concurrent.SemaphoreControlledChannel

capacity, extract, insert, offer, poll, put, size, take

Field Details

in_

protected ObjectInputStream in_

inp_

protected final PipedInputStream inp_

out_

protected ObjectOutputStream out_

outp_

protected final PipedOutputStream outp_

Constructor Details

PipedChannel

public PipedChannel()

Method Details

extract

protected Object extract()
Shared mechanics for take-based methods *
Overrides:
extract in interface SemaphoreControlledChannel

in

protected ObjectInputStream in()
Return input stream, first constructing if necessary. Needed because Object streams can block on open.

insert

protected void insert(Object x)
Shared mechanics for put-based methods *
Overrides:
insert in interface SemaphoreControlledChannel

out

protected ObjectOutputStream out()
Return output stream, first constructing if necessary. Needed because Object streams can block on open.

peek

public Object peek()
Stubbed out for now *
Specified by:
peek in interface Channel