70 |
70 |
71 protected void implConfigureBlocking(boolean block) throws IOException { |
71 protected void implConfigureBlocking(boolean block) throws IOException { |
72 sc.configureBlocking(block); |
72 sc.configureBlocking(block); |
73 } |
73 } |
74 |
74 |
75 public boolean translateReadyOps(int ops, int initialOps, |
75 public boolean translateReadyOps(int ops, int initialOps, SelectionKeyImpl ski) { |
76 SelectionKeyImpl sk) { |
76 int intOps = ski.nioInterestOps(); |
77 int intOps = sk.nioInterestOps(); // Do this just once, it synchronizes |
77 int oldOps = ski.nioReadyOps(); |
78 int oldOps = sk.nioReadyOps(); |
|
79 int newOps = initialOps; |
78 int newOps = initialOps; |
80 |
79 |
81 if ((ops & Net.POLLNVAL) != 0) |
80 if ((ops & Net.POLLNVAL) != 0) |
82 throw new Error("POLLNVAL detected"); |
81 throw new Error("POLLNVAL detected"); |
83 |
82 |
84 if ((ops & (Net.POLLERR | Net.POLLHUP)) != 0) { |
83 if ((ops & (Net.POLLERR | Net.POLLHUP)) != 0) { |
85 newOps = intOps; |
84 newOps = intOps; |
86 sk.nioReadyOps(newOps); |
85 ski.nioReadyOps(newOps); |
87 return (newOps & ~oldOps) != 0; |
86 return (newOps & ~oldOps) != 0; |
88 } |
87 } |
89 |
88 |
90 if (((ops & Net.POLLOUT) != 0) && |
89 if (((ops & Net.POLLOUT) != 0) && |
91 ((intOps & SelectionKey.OP_WRITE) != 0)) |
90 ((intOps & SelectionKey.OP_WRITE) != 0)) |
92 newOps |= SelectionKey.OP_WRITE; |
91 newOps |= SelectionKey.OP_WRITE; |
93 |
92 |
94 sk.nioReadyOps(newOps); |
93 ski.nioReadyOps(newOps); |
95 return (newOps & ~oldOps) != 0; |
94 return (newOps & ~oldOps) != 0; |
96 } |
95 } |
97 |
96 |
98 public boolean translateAndUpdateReadyOps(int ops, SelectionKeyImpl sk) { |
97 public boolean translateAndUpdateReadyOps(int ops, SelectionKeyImpl ski) { |
99 return translateReadyOps(ops, sk.nioReadyOps(), sk); |
98 return translateReadyOps(ops, ski.nioReadyOps(), ski); |
100 } |
99 } |
101 |
100 |
102 public boolean translateAndSetReadyOps(int ops, SelectionKeyImpl sk) { |
101 public boolean translateAndSetReadyOps(int ops, SelectionKeyImpl ski) { |
103 return translateReadyOps(ops, 0, sk); |
102 return translateReadyOps(ops, 0, ski); |
104 } |
103 } |
105 |
104 |
106 public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) { |
105 public int translateInterestOps(int ops) { |
|
106 int newOps = 0; |
107 if ((ops & SelectionKey.OP_WRITE) != 0) |
107 if ((ops & SelectionKey.OP_WRITE) != 0) |
108 ops = Net.POLLOUT; |
108 newOps |= Net.POLLOUT; |
109 sk.selector.putEventOps(sk, ops); |
109 return newOps; |
110 } |
110 } |
111 |
111 |
112 public int write(ByteBuffer src) throws IOException { |
112 public int write(ByteBuffer src) throws IOException { |
113 try { |
113 try { |
114 return sc.write(src); |
114 return sc.write(src); |