Package java.nio.channels

Examples of java.nio.channels.SelectableChannel.configureBlocking()


            SelectableChannel selectableChannel = (SelectableChannel)descriptor.getChannel();
            synchronized (selectableChannel.blockingLock()) {
                boolean oldBlocking = selectableChannel.isBlocking();
                try {
                    if (oldBlocking) {
                        selectableChannel.configureBlocking(false);
                    }
                    return descriptor.write(ByteBuffer.wrap(buf.getUnsafeBytes(), buf.begin(), buf.length()));
                } finally {
                    if (oldBlocking) {
                        selectableChannel.configureBlocking(oldBlocking);
View Full Code Here


                        selectableChannel.configureBlocking(false);
                    }
                    return descriptor.write(ByteBuffer.wrap(buf.getUnsafeBytes(), buf.begin(), buf.length()));
                } finally {
                    if (oldBlocking) {
                        selectableChannel.configureBlocking(oldBlocking);
                    }
                }
            }
        } else {
            // can't set nonblocking, so go ahead with it...not much else we can do
View Full Code Here

        if (descriptor.getChannel() instanceof SelectableChannel) {
            SelectableChannel selectableChannel = (SelectableChannel)descriptor.getChannel();
            synchronized (selectableChannel.blockingLock()) {
                boolean oldBlocking = selectableChannel.isBlocking();
                try {
                    selectableChannel.configureBlocking(false);
                    return readpartial(number);
                } finally {
                    selectableChannel.configureBlocking(oldBlocking);
                }
            }
View Full Code Here

                boolean oldBlocking = selectableChannel.isBlocking();
                try {
                    selectableChannel.configureBlocking(false);
                    return readpartial(number);
                } finally {
                    selectableChannel.configureBlocking(oldBlocking);
                }
            }
        } else if (descriptor.getChannel() instanceof FileChannel) {
            return fread(number);
        } else {
View Full Code Here

                        SelectableChannel ch = (SelectableChannel) stream.getDescriptor().getChannel();
                        synchronized (ch.blockingLock()) {
                            boolean oldBlocking = ch.isBlocking();
                            try {
                                if (!oldBlocking) {
                                    ch.configureBlocking(true);
                                }
                                return stream.bufferedRead(ByteBuffer.wrap(bytes, off, len), true);
                            } finally {
                                if (!oldBlocking) {
                                    ch.configureBlocking(oldBlocking);
View Full Code Here

                                    ch.configureBlocking(true);
                                }
                                return stream.bufferedRead(ByteBuffer.wrap(bytes, off, len), true);
                            } finally {
                                if (!oldBlocking) {
                                    ch.configureBlocking(oldBlocking);
                                }
                            }
                        }
                    } else {
                        return stream.bufferedRead(ByteBuffer.wrap(bytes, off, len), true);
View Full Code Here

                        SelectableChannel ch = (SelectableChannel) stream.getDescriptor().getChannel();
                        synchronized (ch.blockingLock()) {
                            boolean oldBlocking = ch.isBlocking();
                            try {
                                if (!oldBlocking) {
                                    ch.configureBlocking(true);
                                }
                                stream.bufferedWrite(ByteBuffer.wrap(bytes, off, len));
                            } finally {
                                if (!oldBlocking) {
                                    ch.configureBlocking(oldBlocking);
View Full Code Here

                                    ch.configureBlocking(true);
                                }
                                stream.bufferedWrite(ByteBuffer.wrap(bytes, off, len));
                            } finally {
                                if (!oldBlocking) {
                                    ch.configureBlocking(oldBlocking);
                                }
                            }
                        }
                    } else {
                        stream.bufferedWrite(ByteBuffer.wrap(bytes, off, len));
View Full Code Here

  private final AsynchronousSocket socket;
  private final CountDownLatch latch = new CountDownLatch(3)// 3 op/callbacks (connect, write, read)
 
  public AsynchronousSocketTest() throws IOException {
    SelectableChannel channel = SocketChannel.open();
    channel.configureBlocking(false);
    socket = new AsynchronousSocket(channel);
  }
 
  @Test
  public void connectWriteAndReadCallbackTest() throws InterruptedException, IOException {
View Full Code Here

    }

    @Override
    protected void init(NioSession session) throws Exception {
        SelectableChannel ch = (SelectableChannel) session.getChannel();
        ch.configureBlocking(false);
        session.setSelectionKey(ch.register(selector, SelectionKey.OP_READ,
                session));
    }

    @Override
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.