< prev index next >

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

Print this page

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

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