50 protected SelectionKeyImpl[] channelArray;
51
52 // In some impls the first entry of channelArray is bogus
53 protected int channelOffset = 0;
54
55 // The number of valid channels in this Selector's poll array
56 protected int totalChannels;
57
58 // True if this Selector has been closed
59 private boolean closed = false;
60
61 // Lock for close and cleanup
62 private Object closeLock = new Object();
63
64 AbstractPollSelectorImpl(SelectorProvider sp, int channels, int offset) {
65 super(sp);
66 this.totalChannels = channels;
67 this.channelOffset = offset;
68 }
69
70 void putEventOps(SelectionKeyImpl sk, int ops) {
71 synchronized (closeLock) {
72 if (closed)
73 throw new ClosedSelectorException();
74 pollWrapper.putEventOps(sk.getIndex(), ops);
75 }
76 }
77
78 public Selector wakeup() {
79 pollWrapper.interrupt();
80 return this;
81 }
82
83 protected abstract int doSelect(long timeout) throws IOException;
84
85 protected void implClose() throws IOException {
86 synchronized (closeLock) {
87 if (closed)
88 return;
89 closed = true;
90 // Deregister channels
|
50 protected SelectionKeyImpl[] channelArray;
51
52 // In some impls the first entry of channelArray is bogus
53 protected int channelOffset = 0;
54
55 // The number of valid channels in this Selector's poll array
56 protected int totalChannels;
57
58 // True if this Selector has been closed
59 private boolean closed = false;
60
61 // Lock for close and cleanup
62 private Object closeLock = new Object();
63
64 AbstractPollSelectorImpl(SelectorProvider sp, int channels, int offset) {
65 super(sp);
66 this.totalChannels = channels;
67 this.channelOffset = offset;
68 }
69
70 public void putEventOps(SelectionKeyImpl sk, int ops) {
71 synchronized (closeLock) {
72 if (closed)
73 throw new ClosedSelectorException();
74 pollWrapper.putEventOps(sk.getIndex(), ops);
75 }
76 }
77
78 public Selector wakeup() {
79 pollWrapper.interrupt();
80 return this;
81 }
82
83 protected abstract int doSelect(long timeout) throws IOException;
84
85 protected void implClose() throws IOException {
86 synchronized (closeLock) {
87 if (closed)
88 return;
89 closed = true;
90 // Deregister channels
|