com.planet_ink.coffee_mud.core
Class CoffeeIOPipe

java.lang.Object
  extended by com.planet_ink.coffee_mud.core.CoffeeIOPipe

public class CoffeeIOPipe
extends java.lang.Object

Similar to Javas pipe, except it's buffered and thread agnostic.


Nested Class Summary
 class CoffeeIOPipe.CMInputStream
          The input stream for a single pipe.
 class CoffeeIOPipe.CMOutputStream
          The output stream for a single pipe.
static class CoffeeIOPipe.CoffeeIOPipes
          A pair of coffee pipes, for using to build a pair of coffee pipe sockets.
static class CoffeeIOPipe.CoffeePipeSocket
          A fake socket that consists of a pair of CoffeePipes.
 
Constructor Summary
CoffeeIOPipe(int bufferSize)
          Construct a single two-way pipe.
CoffeeIOPipe(int bufferSize, java.lang.Runnable writeCallback)
          Construct a single two-way pipe.
 
Method Summary
 void close()
          Closes the input stream.
 CoffeeIOPipe.CMInputStream getInputStream()
          Returns the input stream
 CoffeeIOPipe.CMOutputStream getOutputStream()
          Returns the pipe output stream
 void setWriteCallback(java.lang.Runnable runner)
          Sets a callback that occurs when a write occurs.
 void shutdownInput()
          Shutdowns the input stream
 void shutdownOutput()
          Shutdowns the output stream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CoffeeIOPipe

public CoffeeIOPipe(int bufferSize,
                    java.lang.Runnable writeCallback)
Construct a single two-way pipe.

Parameters:
bufferSize - size of the buffer
writeCallback - optional runnable called when a write occurs.

CoffeeIOPipe

public CoffeeIOPipe(int bufferSize)
Construct a single two-way pipe.

Parameters:
bufferSize - size of the buffer
Method Detail

getInputStream

public CoffeeIOPipe.CMInputStream getInputStream()
Returns the input stream

Returns:
the input stream

getOutputStream

public CoffeeIOPipe.CMOutputStream getOutputStream()
Returns the pipe output stream

Returns:
the pipe output stream

setWriteCallback

public void setWriteCallback(java.lang.Runnable runner)
Sets a callback that occurs when a write occurs. null is ok.

Parameters:
runner - the optional callback

shutdownInput

public void shutdownInput()
Shutdowns the input stream


shutdownOutput

public void shutdownOutput()
Shutdowns the output stream


close

public void close()
Closes the input stream.