public static final Condition newCondition(Channel channel, int ops) throws IOException { return newCondition(channel, ops, new Object()); } public static void waitForIO(Channel channel, int op) throws InterruptedException, IOException {
public static int blockingRead(ReadableByteChannel channel, ByteBuffer buf) throws IOException { return read(channel, buf, true); } public static int blockingWrite(WritableByteChannel channel, ByteBuffer buf) throws IOException {
public static void awaitReadable(ReadableByteChannel channel) throws InterruptedException, IOException { waitForIO(channel, SelectionKey.OP_READ); } public static void awaitWritable(WritableByteChannel channel) throws InterruptedException, IOException {
private static IOSelector getSelector(Channel channel) throws IOException { if (!(channel instanceof SelectableChannel)) { throw new IllegalArgumentException("channel must be a SelectableChannel"); } return getSelector(((SelectableChannel) channel).provider()); } public static final Condition newCondition(Channel channel, int ops, Object monitor) throws IOException {
public static int blockingWrite(WritableByteChannel channel, ByteBuffer buf) throws IOException { return write(channel, buf, true); } }
public static int write(WritableByteChannel channel, ByteBuffer buf, boolean blocking) throws IOException { do { int n = channel.write(buf); if (n != 0 || !blocking || !(channel instanceof SelectableChannel) || !buf.hasRemaining()) { return n; } try { awaitWritable(channel); } catch (InterruptedException ex) { throw new InterruptedIOException(ex.getMessage()); } } while (true); } public static int blockingRead(ReadableByteChannel channel, ByteBuffer buf) throws IOException {
public static int read(ReadableByteChannel channel, ByteBuffer buf, boolean blocking) throws IOException { do { int n = channel.read(buf); if (n != 0 || !blocking || !(channel instanceof SelectableChannel) || !buf.hasRemaining()) { return n; } try { awaitReadable(channel); } catch (InterruptedException ex) { throw new InterruptedIOException(ex.getMessage()); } } while (true); } public static int write(WritableByteChannel channel, ByteBuffer buf, boolean blocking) throws IOException {
private static IOSelector getSelector(Channel channel) throws IOException { if (!(channel instanceof SelectableChannel)) { throw new IllegalArgumentException("channel must be a SelectableChannel"); } return getSelector(((SelectableChannel) channel).provider()); } public static final Condition newCondition(Channel channel, int ops, Object monitor) throws IOException {
public static int blockingWrite(WritableByteChannel channel, ByteBuffer buf) throws IOException { return write(channel, buf, true); } }
public static int write(WritableByteChannel channel, ByteBuffer buf, boolean blocking) throws IOException { do { int n = channel.write(buf); if (n != 0 || !blocking || !(channel instanceof SelectableChannel) || !buf.hasRemaining()) { return n; } try { awaitWritable(channel); } catch (InterruptedException ex) { throw new InterruptedIOException(ex.getMessage()); } } while (true); } public static int blockingRead(ReadableByteChannel channel, ByteBuffer buf) throws IOException {
public static int read(ReadableByteChannel channel, ByteBuffer buf, boolean blocking) throws IOException { do { int n = channel.read(buf); if (n != 0 || !blocking || !(channel instanceof SelectableChannel) || !buf.hasRemaining()) { return n; } try { awaitReadable(channel); } catch (InterruptedException ex) { throw new InterruptedIOException(ex.getMessage()); } } while (true); } public static int write(WritableByteChannel channel, ByteBuffer buf, boolean blocking) throws IOException {
private static IOSelector getSelector(Channel channel) throws IOException { if (!(channel instanceof SelectableChannel)) { throw new IllegalArgumentException("channel must be a SelectableChannel"); } return getSelector(((SelectableChannel) channel).provider()); } public static final Condition newCondition(Channel channel, int ops, Object monitor) throws IOException {
public static void awaitReadable(ReadableByteChannel channel) throws InterruptedException, IOException { waitForIO(channel, SelectionKey.OP_READ); } public static void awaitWritable(WritableByteChannel channel) throws InterruptedException, IOException {
public static final Condition newCondition(Channel channel, int ops) throws IOException { return newCondition(channel, ops, new Object()); } public static void waitForIO(Channel channel, int op) throws InterruptedException, IOException {
public static int blockingWrite(WritableByteChannel channel, ByteBuffer buf) throws IOException { return write(channel, buf, true); } }
public static int write(WritableByteChannel channel, ByteBuffer buf, boolean blocking) throws IOException { do { int n = channel.write(buf); if (n != 0 || !blocking || !(channel instanceof SelectableChannel) || !buf.hasRemaining()) { return n; } try { awaitWritable(channel); } catch (InterruptedException ex) { throw new InterruptedIOException(ex.getMessage()); } } while (true); } public static int blockingRead(ReadableByteChannel channel, ByteBuffer buf) throws IOException {
public static int blockingRead(ReadableByteChannel channel, ByteBuffer buf) throws IOException { return read(channel, buf, true); } public static int blockingWrite(WritableByteChannel channel, ByteBuffer buf) throws IOException {
public static int read(ReadableByteChannel channel, ByteBuffer buf, boolean blocking) throws IOException { do { int n = channel.read(buf); if (n != 0 || !blocking || !(channel instanceof SelectableChannel) || !buf.hasRemaining()) { return n; } try { awaitReadable(channel); } catch (InterruptedException ex) { throw new InterruptedIOException(ex.getMessage()); } } while (true); } public static int write(WritableByteChannel channel, ByteBuffer buf, boolean blocking) throws IOException {
private static IOSelector getSelector(Channel channel) throws IOException { if (!(channel instanceof SelectableChannel)) { throw new IllegalArgumentException("channel must be a SelectableChannel"); } return getSelector(((SelectableChannel) channel).provider()); } public static final Condition newCondition(Channel channel, int ops, Object monitor) throws IOException {
public static void awaitWritable(WritableByteChannel channel) throws InterruptedException, IOException { waitForIO(channel, SelectionKey.OP_WRITE); } public static int read(ReadableByteChannel channel, ByteBuffer buf, boolean blocking) throws IOException {