|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.OutputStream
org.norther.tammi.acorn.nio.ChannelOutputStream
public class ChannelOutputStream
A non-blocking channel output stream which may wait until ready.
If a selection key is given, the stream sets OP_WRITE to the interest set of the key and waits for the buffer, when it needs it flushed, until a timeout has elapsed or until notified. After the timeout or the notification, it synchronizes the buffer with the channel. The notifier thread may also flush the buffer before notifying the stream or if the stream is not in the wait state.
Note that all I/O operations are synchronized on the buffer.
Constructor Summary | |
---|---|
ChannelOutputStream(SelectionKey key,
WritableByteChannel c,
ByteBuffer b,
long t)
Constructs a new stream. |
Method Summary | |
---|---|
void |
close()
|
void |
flush()
|
long |
getTimeout()
Gets the waiting timeout of this stream. |
void |
setTimeout(long t)
Sets the waiting timeout of this stream. |
boolean |
sync()
Syncs the stream with the channel by notifying the thread waiting on the buffer. |
void |
write(byte[] bb,
int off,
int len)
|
void |
write(int b)
|
Methods inherited from class java.io.OutputStream |
---|
write |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ChannelOutputStream(SelectionKey key, WritableByteChannel c, ByteBuffer b, long t)
key
- the selection key.c
- the writable channel.b
- the buffer in the put state.t
- timeout in msecs to wait until ready.Method Detail |
---|
public void write(int b) throws IOException
write
in class OutputStream
IOException
public void write(byte[] bb, int off, int len) throws IOException
write
in class OutputStream
IOException
public void flush() throws IOException
flush
in interface Flushable
flush
in class OutputStream
IOException
public void close() throws IOException
close
in interface Closeable
close
in class OutputStream
IOException
public long getTimeout()
public void setTimeout(long t)
t
- the timeout in msecs.public boolean sync() throws IOException
IOException
- on I/O errors.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |