Package java.nio.channels

Examples of java.nio.channels.Selector.selectNow()


                            selectCnt);

                    rebuildSelector();

                    // Select again to populate selectedKeys.
                    selector.selectNow();
                    selectCnt = 1;
                    break;
                }

                currentTimeNanos = System.nanoTime();
View Full Code Here


            for (int i = 0; i < selectors.size(); i++) {
                Selector selector = selectors.get(i);
                // if it is a JDK selector, cache it
                if (selector.provider() == SelectorProvider.provider()) {
                    // clear cancelled keys (with selectNow) and return to pool
                    selector.selectNow();
                    context.runtime.getSelectorPool().put(selector);
                } else {
                    selector.close();
                }
            }
View Full Code Here

            long selectDeadLineNanos = currentTimeNanos + delayNanos(currentTimeNanos);
            for (;;) {
                long timeoutMillis = (selectDeadLineNanos - currentTimeNanos + 500000L) / 1000000L;
                if (timeoutMillis <= 0) {
                    if (selectCnt == 0) {
                        selector.selectNow();
                        selectCnt = 1;
                    }
                    break;
                }
View Full Code Here

                    rebuildSelector();
                    selector = this.selector;

                    // Select again to populate selectedKeys.
                    selector.selectNow();
                    selectCnt = 1;
                    break;
                }

                currentTimeNanos = time;
View Full Code Here

                !selectorRunner.getPostponedTasks().isEmpty();
       
        if (!hasPostponedTasks) {
            hasSelectedKeys = selector.select(selectTimeout) > 0;
        } else {
            hasSelectedKeys = selector.selectNow() > 0;
        }

        if (IS_WORKAROUND_SELECTOR_SPIN) {
            selectorRunner.checkSelectorSpin(
                    hasSelectedKeys || hasPostponedTasks,
View Full Code Here

    finally
    {
      if (key.isValid())
      {
        key.cancel();
        selector.selectNow();
      }
    }
  }

View Full Code Here

            long selectDeadLineNanos = currentTimeNanos + delayNanos(currentTimeNanos);
            for (;;) {
                long timeoutMillis = (selectDeadLineNanos - currentTimeNanos + 500000L) / 1000000L;
                if (timeoutMillis <= 0) {
                    if (selectCnt == 0) {
                        selector.selectNow();
                        selectCnt = 1;
                    }
                    break;
                }
View Full Code Here

                    rebuildSelector();
                    selector = this.selector;

                    // Select again to populate selectedKeys.
                    selector.selectNow();
                    selectCnt = 1;
                    break;
                }

                currentTimeNanos = time;
View Full Code Here

                !selectorRunner.getPostponedTasks().isEmpty();
       
        if (!hasPostponedTasks) {
            hasSelectedKeys = selector.select(selectTimeout) > 0;
        } else {
            hasSelectedKeys = selector.selectNow() > 0;
        }

        if (IS_WORKAROUND_SELECTOR_SPIN) {
            selectorRunner.checkSelectorSpin(
                    hasSelectedKeys || hasPostponedTasks,
View Full Code Here

        Selector serverSelector = Selector.open();
        ServerSocketChannel server = ServerSocketChannel.open();
        server.configureBlocking(false);
        server.socket().bind(address, 5000);
        server.register(serverSelector, SelectionKey.OP_ACCEPT);
        serverSelector.selectNow();

        log("Setting up client");
        ClientThread client = new ClientThread(address);
        client.start();
        Thread.sleep(100);
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.