< prev index next >

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

Print this page

27 import java.io.IOException;
28 import static sun.nio.ch.WEPoll.*;
29 
30 /**
31  * Poller implementation based on wepoll.
32  */
33 class WEPollPoller extends Poller {
34     private static final int MAX_EVENTS_TO_POLL = 256;
35     private static final int ENOENT = 2;
36 
37     private final long handle;
38     private final int event;
39     private final long address;
40 
41     WEPollPoller(boolean read) throws IOException {
42         this.handle = WEPoll.create();
43         this.event = (read) ? EPOLLIN : EPOLLOUT;
44         this.address = WEPoll.allocatePollArray(MAX_EVENTS_TO_POLL);
45     }
46 






47     @Override
48     void implRegister(int fdVal) throws IOException {
49         int err = WEPoll.ctl(handle, EPOLL_CTL_ADD, fdVal, (event | EPOLLONESHOT));
50         if (err != 0)
51             throw new IOException("epoll_ctl failed: " + err);
52     }
53 
54     @Override
55     void implDeregister(int fdVal, boolean polled) {
56         WEPoll.ctl(handle, EPOLL_CTL_DEL, fdVal, 0);
57     }
58 
59     @Override
60     int poll(int timeout) throws IOException {
61         int n = WEPoll.wait(handle, address, MAX_EVENTS_TO_POLL, timeout);
62         int i = 0;
63         while (i < n) {
64             long event = WEPoll.getEvent(address, i);
65             int fdVal = WEPoll.getDescriptor(event);
66             polled(fdVal);

27 import java.io.IOException;
28 import static sun.nio.ch.WEPoll.*;
29 
30 /**
31  * Poller implementation based on wepoll.
32  */
33 class WEPollPoller extends Poller {
34     private static final int MAX_EVENTS_TO_POLL = 256;
35     private static final int ENOENT = 2;
36 
37     private final long handle;
38     private final int event;
39     private final long address;
40 
41     WEPollPoller(boolean read) throws IOException {
42         this.handle = WEPoll.create();
43         this.event = (read) ? EPOLLIN : EPOLLOUT;
44         this.address = WEPoll.allocatePollArray(MAX_EVENTS_TO_POLL);
45     }
46 
47     @Override
48     void close() {
49         WEPoll.close(handle);
50         WEPoll.freePollArray(address);
51     }
52 
53     @Override
54     void implRegister(int fdVal) throws IOException {
55         int err = WEPoll.ctl(handle, EPOLL_CTL_ADD, fdVal, (event | EPOLLONESHOT));
56         if (err != 0)
57             throw new IOException("epoll_ctl failed: " + err);
58     }
59 
60     @Override
61     void implDeregister(int fdVal, boolean polled) {
62         WEPoll.ctl(handle, EPOLL_CTL_DEL, fdVal, 0);
63     }
64 
65     @Override
66     int poll(int timeout) throws IOException {
67         int n = WEPoll.wait(handle, address, MAX_EVENTS_TO_POLL, timeout);
68         int i = 0;
69         while (i < n) {
70             long event = WEPoll.getEvent(address, i);
71             int fdVal = WEPoll.getDescriptor(event);
72             polled(fdVal);
< prev index next >