net.sf.asyncobjects.io
Class Pipe<D extends BatchedData<D>,I extends AInput<D>,O extends AOutput<D>,C extends AChannel<D,I,O>>

java.lang.Object
  extended by net.sf.asyncobjects.AsyncUnicastServer<C>
      extended by net.sf.asyncobjects.io.Pipe<D,I,O,C>
Type Parameters:
D - a batched data type
I - an input type
O - an output type
C - a channel type
All Implemented Interfaces:
ACloseable, AsyncObject, ExplicitSharing, AChannel<D,I,O>
Direct Known Subclasses:
BytePipe, TextPipe

public abstract class Pipe<D extends BatchedData<D>,I extends AInput<D>,O extends AOutput<D>,C extends AChannel<D,I,O>>
extends AsyncUnicastServer<C>
implements AChannel<D,I,O>

A pipe is pair of output stream and input stream, what is written to output stream, could be later read from input stream. The object supports AChannel interface. Note that input supports AInput.pushback(BatchedData) operation.

See Also:
AChannel

Nested Class Summary
 class Pipe.InternalPipeInput
          This is an internal class.
 class Pipe.InternalPipeOutput
          This is an internal class.
 
Constructor Summary
Pipe(int size)
          make a pipe
 
Method Summary
 Promise<Void> close()
          Channel close
protected abstract  I createInput()
           
protected abstract  O createOutput()
           
 Promise<I> getInput()
           
 Promise<O> getOutput()
           
 Promise<Void> pushback(D pushbackData)
          Push data back to the pipe
 
Methods inherited from class net.sf.asyncobjects.AsyncUnicastServer
dereference, export, isImmediate, myVat, promise
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.asyncobjects.AsyncObject
dereference, isImmediate
 

Constructor Detail

Pipe

public Pipe(int size)
make a pipe

Parameters:
size - buffer size for pipe
Method Detail

createOutput

protected abstract O createOutput()
Returns:
an created output

createInput

protected abstract I createInput()
Returns:
an created input

getInput

public Promise<I> getInput()
Specified by:
getInput in interface AChannel<D extends BatchedData<D>,I extends AInput<D>,O extends AOutput<D>>
Returns:
input stream
See Also:
AChannel.getInput()

getOutput

public Promise<O> getOutput()
Specified by:
getOutput in interface AChannel<D extends BatchedData<D>,I extends AInput<D>,O extends AOutput<D>>
Returns:
output stream
See Also:
AChannel.getOutput()

pushback

public Promise<Void> pushback(D pushbackData)
Push data back to the pipe

Parameters:
pushbackData - a data to push backk
Returns:
a promise that resolves when operation finishes

close

public Promise<Void> close()
Channel close

Specified by:
close in interface ACloseable
Returns:
proimse that resolves when channle is closed.


Copyright © 2002-2007 Constantine Plotnikov. All Rights Reserved.