Top Description Inners Fields Constructors Methods
org.jruby.util.io

public Class BlockingIO

extends Object
Class Inheritance
Imports
java.io.IOException, .InterruptedIOException, java.nio.ByteBuffer, java.nio.channels.Channel, .ReadableByteChannel, .SelectableChannel, .SelectionKey, .Selector, .WritableByteChannel, java.nio.channels.spi.SelectorProvider, java.util.HashSet, .LinkedList, .List, .Map, .Set, java.util.concurrent.ConcurrentHashMap, .ConcurrentLinkedQueue, .TimeUnit

A Utility class to emulate blocking I/O operations on non-blocking channels.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
pack-priv static class
pack-priv static class

Field Summary

Modifier and TypeField and Description
private static final Map<SelectorProvider, BlockingIO.IOSelector>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static void
public static void
public static int
public static int
private static BlockingIO.IOSelector
private static BlockingIO.IOSelector
public static final BlockingIO.Condition
newCondition(Channel channel, int ops, Object monitor)

public static final BlockingIO.Condition
newCondition(Channel channel, int ops)

public static int
read(ReadableByteChannel channel, ByteBuffer buf, boolean blocking)

public static void
waitForIO(Channel channel, int op)

public static int
write(WritableByteChannel channel, ByteBuffer buf, boolean blocking)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

selectorsback to summary
private static final Map<SelectorProvider, BlockingIO.IOSelector> selectors

Constructor Detail

BlockingIOback to summary
public BlockingIO()

Method Detail

awaitReadableback to summary
public static void awaitReadable(ReadableByteChannel channel) throws InterruptedException, IOException
awaitWritableback to summary
public static void awaitWritable(WritableByteChannel channel) throws InterruptedException, IOException
blockingReadback to summary
public static int blockingRead(ReadableByteChannel channel, ByteBuffer buf) throws IOException
blockingWriteback to summary
public static int blockingWrite(WritableByteChannel channel, ByteBuffer buf) throws IOException
getSelectorback to summary
private static BlockingIO.IOSelector getSelector(SelectorProvider provider) throws IOException
getSelectorback to summary
private static BlockingIO.IOSelector getSelector(Channel channel) throws IOException
newConditionback to summary
public static final BlockingIO.Condition newCondition(Channel channel, int ops, Object monitor) throws IOException
newConditionback to summary
public static final BlockingIO.Condition newCondition(Channel channel, int ops) throws IOException
readback to summary
public static int read(ReadableByteChannel channel, ByteBuffer buf, boolean blocking) throws IOException
waitForIOback to summary
public static void waitForIO(Channel channel, int op) throws InterruptedException, IOException
writeback to summary
public static int write(WritableByteChannel channel, ByteBuffer buf, boolean blocking) throws IOException
org.jruby.util.io back to summary

public final Class BlockingIO.Condition

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final BlockingIO.IOChannel

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
public boolean
await(long timeout, TimeUnit unit)

public void
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

channelback to summary
private final BlockingIO.IOChannel channel

Constructor Detail

Conditionback to summary
pack-priv Condition(BlockingIO.IOChannel channel)

Method Detail

awaitback to summary
public boolean await() throws InterruptedException
awaitback to summary
public boolean await(long timeout, TimeUnit unit) throws InterruptedException
cancelback to summary
public void cancel()
interruptback to summary
public void interrupt()
org.jruby.util.io back to summary

pack-priv final Class BlockingIO.IOChannel

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final SelectableChannel
private boolean
private final Object
pack-priv final int
private boolean
private boolean

Constructor Summary

AccessConstructor and Description
pack-priv
IOChannel(SelectableChannel channel, int ops, Object monitor)

Method Summary

Modifier and TypeMethod and Description
public final boolean
public final boolean
await(final long timeout, TimeUnit unit)

public final void
public final void
wakeup(boolean ready)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

channelback to summary
pack-priv final SelectableChannel channel
interruptedback to summary
private boolean interrupted
monitorback to summary
private final Object monitor
opsback to summary
pack-priv final int ops
readyback to summary
private boolean ready
wokenback to summary
private boolean woken

Constructor Detail

IOChannelback to summary
pack-priv IOChannel(SelectableChannel channel, int ops, Object monitor)

Method Detail

awaitback to summary
public final boolean await() throws InterruptedException
awaitback to summary
public final boolean await(final long timeout, TimeUnit unit) throws InterruptedException
interruptback to summary
public final void interrupt()
wakeupback to summary
public final void wakeup(boolean ready)
org.jruby.util.io back to summary

pack-priv final Class BlockingIO.IOSelector

extends Object
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable

Field Summary

Modifier and TypeField and Description
private final ConcurrentLinkedQueue<BlockingIO.IOChannel>
private final Selector

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
pack-priv BlockingIO.Condition
add(Channel channel, int ops, Object monitor)

public void
await(Channel channel, int op)

public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

registrationQueueback to summary
private final ConcurrentLinkedQueue<BlockingIO.IOChannel> registrationQueue
selectorback to summary
private final Selector selector

Constructor Detail

IOSelectorback to summary
public IOSelector(SelectorProvider provider) throws IOException

Method Detail

addback to summary
pack-priv BlockingIO.Condition add(Channel channel, int ops, Object monitor)
awaitback to summary
public void await(Channel channel, int op) throws InterruptedException
runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.