Java Code Examples for java.nio.channels.SelectionKey#interestOpsOr()
The following examples show how to use
java.nio.channels.SelectionKey#interestOpsOr() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NioSession.java From jane with GNU Lesser General Public License v3.0 | 6 votes |
/** * Set the session to be informed when a read event should be processed * * @param isInterested <tt>true</tt> for registering, <tt>false</tt> for removing * @throws Exception If there was a problem while registering the session */ void setInterestedInRead(boolean isInterested) { if (isClosing()) return; SelectionKey key = selKey; if (key == null || !key.isValid()) return; readSuspended = !isInterested; try { final boolean modified; if (isInterested) modified = (key.interestOpsOr(SelectionKey.OP_READ) & SelectionKey.OP_READ) == 0; else modified = (key.interestOpsAnd(~SelectionKey.OP_READ) & SelectionKey.OP_READ) != 0; if (modified && !nioProcessor.isInProcessorThread()) nioProcessor.wakeup(); } catch (Exception e) { filterChain.fireExceptionCaught(e); } }
Example 2
Source File: NioSession.java From jane with GNU Lesser General Public License v3.0 | 5 votes |
/** * Set the session to be informed when a write event should be processed * * @param isInterested <tt>true</tt> for registering, <tt>false</tt> for removing * @throws Exception If there was a problem while registering the session */ void setInterestedInWrite(boolean isInterested) { SelectionKey key = selKey; if (key == null || !key.isValid()) return; if (isInterested) key.interestOpsOr(SelectionKey.OP_WRITE); else key.interestOpsAnd(~SelectionKey.OP_WRITE); }