equal
deleted
inserted
replaced
31 import java.nio.channels.Selector; |
31 import java.nio.channels.Selector; |
32 import java.nio.channels.spi.AbstractSelectionKey; |
32 import java.nio.channels.spi.AbstractSelectionKey; |
33 |
33 |
34 |
34 |
35 /** |
35 /** |
36 * An implementation of SelectionKey for Solaris. |
36 * An implementation of SelectionKey. |
37 */ |
37 */ |
38 |
38 |
39 public class SelectionKeyImpl |
39 public final class SelectionKeyImpl |
40 extends AbstractSelectionKey |
40 extends AbstractSelectionKey |
41 { |
41 { |
42 |
42 |
43 final SelChImpl channel; // package-private |
43 final SelChImpl channel; // package-private |
44 public final SelectorImpl selector; |
44 public final SelectorImpl selector; |
52 SelectionKeyImpl(SelChImpl ch, SelectorImpl sel) { |
52 SelectionKeyImpl(SelChImpl ch, SelectorImpl sel) { |
53 channel = ch; |
53 channel = ch; |
54 selector = sel; |
54 selector = sel; |
55 } |
55 } |
56 |
56 |
|
57 @Override |
57 public SelectableChannel channel() { |
58 public SelectableChannel channel() { |
58 return (SelectableChannel)channel; |
59 return (SelectableChannel)channel; |
59 } |
60 } |
60 |
61 |
|
62 @Override |
61 public Selector selector() { |
63 public Selector selector() { |
62 return selector; |
64 return (Selector)selector; |
63 } |
65 } |
64 |
66 |
65 int getIndex() { // package-private |
67 int getIndex() { // package-private |
66 return index; |
68 return index; |
67 } |
69 } |
73 private void ensureValid() { |
75 private void ensureValid() { |
74 if (!isValid()) |
76 if (!isValid()) |
75 throw new CancelledKeyException(); |
77 throw new CancelledKeyException(); |
76 } |
78 } |
77 |
79 |
|
80 @Override |
78 public int interestOps() { |
81 public int interestOps() { |
79 ensureValid(); |
82 ensureValid(); |
80 return interestOps; |
83 return interestOps; |
81 } |
84 } |
82 |
85 |
|
86 @Override |
83 public SelectionKey interestOps(int ops) { |
87 public SelectionKey interestOps(int ops) { |
84 ensureValid(); |
88 ensureValid(); |
85 return nioInterestOps(ops); |
89 return nioInterestOps(ops); |
86 } |
90 } |
87 |
91 |
|
92 @Override |
88 public int readyOps() { |
93 public int readyOps() { |
89 ensureValid(); |
94 ensureValid(); |
90 return readyOps; |
95 return readyOps; |
91 } |
96 } |
92 |
97 |
129 sb.append(", invalid"); |
134 sb.append(", invalid"); |
130 } |
135 } |
131 return sb.toString(); |
136 return sb.toString(); |
132 } |
137 } |
133 |
138 |
|
139 // used by Selector implementations to record when the key was selected |
|
140 int lastPolled; |
134 } |
141 } |