(long interval)
| 66 | } |
| 67 | |
| 68 | public int doSelect(long interval) throws IOException { |
| 69 | if (! isOpen()) { |
| 70 | throw new ClosedSelectorException(); |
| 71 | } |
| 72 | |
| 73 | selectedKeys.clear(); |
| 74 | |
| 75 | if (clearWoken()) interval = -1; |
| 76 | |
| 77 | int max=0; |
| 78 | for (Iterator<SelectionKey> it = keys.iterator(); |
| 79 | it.hasNext();) |
| 80 | { |
| 81 | SelectionKey key = it.next(); |
| 82 | SelectableChannel c = key.channel(); |
| 83 | int socket = c.socketFD(); |
| 84 | if (c.isOpen()) { |
| 85 | key.readyOps(0); |
| 86 | max = natSelectUpdateInterestSet |
| 87 | (socket, key.interestOps(), state, max); |
| 88 | } else { |
| 89 | natSelectClearAll(socket, state); |
| 90 | it.remove(); |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | int r = natDoSocketSelect(state, max, interval); |
| 95 | |
| 96 | if (r > 0) { |
| 97 | for (SelectionKey key : keys) { |
| 98 | SelectableChannel c = key.channel(); |
| 99 | int socket = c.socketFD(); |
| 100 | int ready = natUpdateReadySet(socket, key.interestOps(), state); |
| 101 | key.readyOps(ready); |
| 102 | if (ready != 0) { |
| 103 | c.handleReadyOps(ready); |
| 104 | selectedKeys.add(key); |
| 105 | } |
| 106 | } |
| 107 | } |
| 108 | clearWoken(); |
| 109 | |
| 110 | return selectedKeys.size(); |
| 111 | } |
| 112 | |
| 113 | public synchronized void close() { |
| 114 | synchronized (lock) { |
no test coverage detected