MCPcopy Create free account
hub / github.com/ReadyTalk/avian / doSelect

Method doSelect

classpath/java/nio/channels/SocketSelector.java:68–111  ·  view source on GitHub ↗
(long interval)

Source from the content-addressed store, hash-verified

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) {

Callers 2

selectNowMethod · 0.95
selectMethod · 0.95

Calls 15

isOpenMethod · 0.95
clearWokenMethod · 0.95
channelMethod · 0.95
socketFDMethod · 0.95
isOpenMethod · 0.95
readyOpsMethod · 0.95
interestOpsMethod · 0.95
natSelectClearAllMethod · 0.95
natDoSocketSelectMethod · 0.95
natUpdateReadySetMethod · 0.95
handleReadyOpsMethod · 0.95

Tested by

no test coverage detected