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