XNIO API 3.1.0.Beta1

org.xnio.channels
Interface SuspendableReadChannel

All Superinterfaces:
Channel, Closeable, CloseableChannel, Configurable, InterruptibleChannel
All Known Subinterfaces:
BoundMultipointMessageChannel, ConnectedMessageChannel, ConnectedSslStreamChannel, ConnectedStreamChannel, MessageChannel, MulticastMessageChannel, MultipointMessageChannel, ReadableMessageChannel, ReadableMultipointMessageChannel, StreamChannel, StreamSourceChannel, SuspendableChannel
All Known Implementing Classes:
AssembledConnectedMessageChannel, AssembledConnectedSslStreamChannel, AssembledConnectedStreamChannel, AssembledMessageChannel, AssembledStreamChannel, EmptyStreamSourceChannel, FramedMessageChannel, PushBackStreamChannel, TranslatingSuspendableChannel

public interface SuspendableReadChannel
extends CloseableChannel

A suspendable readable channel. This type of channel is associated with a listener which can suspend and resume reads as needed.


Method Summary
 void awaitReadable()
          Block until this channel becomes readable again.
 void awaitReadable(long time, TimeUnit timeUnit)
          Block until this channel becomes readable again, or until the timeout expires.
 ChannelListener.Setter<? extends SuspendableReadChannel> getCloseSetter()
          Get the setter which can be used to change the close listener for this channel.
 ChannelListener.Setter<? extends SuspendableReadChannel> getReadSetter()
          Get the setter which can be used to change the read listener for this channel.
 XnioExecutor getReadThread()
          Get the read thread for this channel.
 boolean isReadResumed()
          Determine whether reads are resumed.
 void resumeReads()
          Resume reads on this channel.
 void shutdownReads()
          Places this readable channel at "end of stream".
 void suspendReads()
          Suspend further read notifications on this channel.
 void wakeupReads()
          Resume reads on this channel, and force the read listener to be triggered even if the channel isn't actually readable.
 
Methods inherited from interface org.xnio.channels.CloseableChannel
close, getWorker
 
Methods inherited from interface java.nio.channels.Channel
isOpen
 
Methods inherited from interface org.xnio.channels.Configurable
getOption, setOption, supportsOption
 

Method Detail

suspendReads

void suspendReads()
Suspend further read notifications on this channel.


resumeReads

void resumeReads()
Resume reads on this channel. The read listener will be called as soon as there is data available to be read.


isReadResumed

boolean isReadResumed()
Determine whether reads are resumed.

Returns:
true if reads are resumed, false if reads are suspended

wakeupReads

void wakeupReads()
Resume reads on this channel, and force the read listener to be triggered even if the channel isn't actually readable.


shutdownReads

void shutdownReads()
                   throws IOException
Places this readable channel at "end of stream". Further reads will result in EOF. Shutting down all directions of a channel will cause CloseableChannel.close() to be called automatically.

Throws:
IOException - if an I/O error occurs

awaitReadable

void awaitReadable()
                   throws IOException
Block until this channel becomes readable again. This method may return spuriously before the channel becomes readable.

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

awaitReadable

void awaitReadable(long time,
                   TimeUnit timeUnit)
                   throws IOException
Block until this channel becomes readable again, or until the timeout expires. This method may return spuriously before the channel becomes readable or the timeout expires.

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

getReadThread

XnioExecutor getReadThread()
Get the read thread for this channel.

Returns:
the thread, or null if none is configured or available

getReadSetter

ChannelListener.Setter<? extends SuspendableReadChannel> getReadSetter()
Get the setter which can be used to change the read listener for this channel.

Returns:
the setter
Since:
2.0

getCloseSetter

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

Specified by:
getCloseSetter in interface CloseableChannel
Returns:
the setter

XNIO API 3.1.0.Beta1

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