XNIO API 2.0.0.GA

org.jboss.xnio.channels
Interface SuspendableWriteChannel

All Superinterfaces:
java.nio.channels.Channel, java.io.Closeable, CloseableChannel, Configurable
All Known Subinterfaces:
ConnectedStreamChannel<A>, DatagramChannel<A>, LocalChannel, MessageChannel, MultipointDatagramChannel<A>, MultipointMessageChannel<A>, MultipointWritableMessageChannel<A>, SslTcpChannel, StreamChannel, StreamSinkChannel, SuspendableChannel, TcpChannel, UdpChannel, WritableMessageChannel

public interface SuspendableWriteChannel
extends CloseableChannel

A suspendable writable channel. This type of channel is associated with a handler which can suspend and resume writes as needed.


Method Summary
 void awaitWritable()
          Block until this channel becomes writable again.
 void awaitWritable(long time, java.util.concurrent.TimeUnit timeUnit)
          Block until this channel becomes writable again, or until the timeout expires.
 boolean flush()
          Flush any waiting partial send or write.
 ChannelListener.Setter<? extends SuspendableWriteChannel> getCloseSetter()
          Get the setter which can be used to change the close handler for this channel.
 ChannelListener.Setter<? extends SuspendableWriteChannel> getWriteSetter()
          Get the setter which can be used to change the write handler for this channel.
 void resumeWrites()
          Resume writes on this channel.
 boolean shutdownWrites()
          Indicate that writing is complete for this channel.
 void suspendWrites()
          Suspend further write notifications on this channel.
 
Methods inherited from interface java.nio.channels.Channel
close, isOpen
 
Methods inherited from interface org.jboss.xnio.channels.Configurable
getOption, setOption, supportsOption
 

Method Detail

suspendWrites

void suspendWrites()
Suspend further write notifications on this channel.


resumeWrites

void resumeWrites()
Resume writes on this channel. The write handler channel listener will be called as soon as the channel becomes writable.


shutdownWrites

boolean shutdownWrites()
                       throws java.io.IOException
Indicate that writing is complete for this channel. Further attempts to write after this method is invoked will result in an exception; however, this method may have to be invoked multiple times in order to complete the shutdown operation. If writes were already shut down successfully, calling this method again will have no additional effect.

Returns:
true if the write channel was closed, or false if the operation would have blocked
Throws:
java.io.IOException - if an I/O error occurs

awaitWritable

void awaitWritable()
                   throws java.io.IOException
Block until this channel becomes writable again. This method may return spuriously before the channel becomes writable.

Throws:
java.io.InterruptedIOException - if the operation is interrupted; the thread's interrupt flag will be set as well
java.io.IOException - if an I/O error occurs
Since:
1.2

awaitWritable

void awaitWritable(long time,
                   java.util.concurrent.TimeUnit timeUnit)
                   throws java.io.IOException
Block until this channel becomes writable again, or until the timeout expires. This method may return spuriously before the channel becomes writable or the timeout expires.

Parameters:
time - the time to wait
timeUnit - the time unit
Throws:
java.io.InterruptedIOException - if the operation is interrupted; the thread's interrupt flag will be set as well
java.io.IOException - if an I/O error occurs
Since:
1.2

getWriteSetter

ChannelListener.Setter<? extends SuspendableWriteChannel> getWriteSetter()
Get the setter which can be used to change the write handler for this channel. When the handler is called, additional notifications are automatically suspended.

Returns:
the setter
Since:
2.0

getCloseSetter

ChannelListener.Setter<? extends SuspendableWriteChannel> getCloseSetter()
Get the setter which can be used to change the close handler for this channel. If the channel is already closed, then the handler will not be called.

Specified by:
getCloseSetter in interface CloseableChannel
Returns:
the setter

flush

boolean flush()
              throws java.io.IOException
Flush any waiting partial send or write. Flushing a channel for which output was shut down is permitted; this method would simply return true in this case, since there is no outstanding data to flush.

Returns:
true if the message was flushed, or false if the result would block
Throws:
java.io.IOException - if an I/O error occurs

XNIO API 2.0.0.GA

Copyright © 2009 JBoss, a division of Red Hat, Inc.