< prev index next >

src/java.base/windows/classes/sun/nio/ch/WEPollSelectorImpl.java

Print this page

 91     private void ensureOpen() {
 92         if (!isOpen())
 93             throw new ClosedSelectorException();
 94     }
 95 
 96     @Override
 97     protected int doSelect(Consumer<SelectionKey> action, long timeout)
 98         throws IOException
 99     {
100         assert Thread.holdsLock(this);
101 
102         // epoll_wait timeout is int
103         int to = (int) Math.min(timeout, Integer.MAX_VALUE);
104         boolean blocking = (to != 0);
105 
106         int numEntries;
107         processUpdateQueue();
108         processDeregisterQueue();
109         try {
110             begin(blocking);
111             numEntries = WEPoll.wait(eph, pollArrayAddress, NUM_EPOLLEVENTS, to);
112         } finally {
113             end(blocking);
114         }
115         processDeregisterQueue();
116         return processEvents(numEntries, action);
117     }
118 





119     /**
120      * Process changes to the interest ops.
121      */
122     private void processUpdateQueue() {
123         assert Thread.holdsLock(this);
124 
125         synchronized (updateLock) {
126             SelectionKeyImpl ski;
127             while ((ski = updateKeys.pollFirst()) != null) {
128                 if (ski.isValid()) {
129                     int fd = ski.getFDVal();
130                     // add to fdToKey if needed
131                     SelectionKeyImpl previous = fdToKey.putIfAbsent(fd, ski);
132                     assert (previous == null) || (previous == ski);
133                     int newOps = ski.translateInterestOps();
134                     int registeredOps = ski.registeredEvents();
135                     if (newOps != registeredOps) {
136                         if (newOps == 0) {
137                             // remove from epoll
138                             WEPoll.ctl(eph, EPOLL_CTL_DEL, fd, 0);

 91     private void ensureOpen() {
 92         if (!isOpen())
 93             throw new ClosedSelectorException();
 94     }
 95 
 96     @Override
 97     protected int doSelect(Consumer<SelectionKey> action, long timeout)
 98         throws IOException
 99     {
100         assert Thread.holdsLock(this);
101 
102         // epoll_wait timeout is int
103         int to = (int) Math.min(timeout, Integer.MAX_VALUE);
104         boolean blocking = (to != 0);
105 
106         int numEntries;
107         processUpdateQueue();
108         processDeregisterQueue();
109         try {
110             begin(blocking);
111             numEntries = poll(to);
112         } finally {
113             end(blocking);
114         }
115         processDeregisterQueue();
116         return processEvents(numEntries, action);
117     }
118 
119     @Override
120     protected int implPoll(long timeout) throws IOException {
121         return WEPoll.wait(eph, pollArrayAddress, NUM_EPOLLEVENTS, (int) timeout);
122     }
123 
124     /**
125      * Process changes to the interest ops.
126      */
127     private void processUpdateQueue() {
128         assert Thread.holdsLock(this);
129 
130         synchronized (updateLock) {
131             SelectionKeyImpl ski;
132             while ((ski = updateKeys.pollFirst()) != null) {
133                 if (ski.isValid()) {
134                     int fd = ski.getFDVal();
135                     // add to fdToKey if needed
136                     SelectionKeyImpl previous = fdToKey.putIfAbsent(fd, ski);
137                     assert (previous == null) || (previous == ski);
138                     int newOps = ski.translateInterestOps();
139                     int registeredOps = ski.registeredEvents();
140                     if (newOps != registeredOps) {
141                         if (newOps == 0) {
142                             // remove from epoll
143                             WEPoll.ctl(eph, EPOLL_CTL_DEL, fd, 0);
< prev index next >