public boolean translateReadyOps ( int ops , int initialOps , SelectionKeyImpl sk ) { int intOps = sk . nioInterestOps ( ) ; // Do this just once, it synchronizes int oldOps = sk . nioReadyOps ( ) ; int newOps = initialOps ; if ( ( ops & PollArrayWrapper . POLLNVAL ) != 0 ) { // This should only happen if this channel is pre-closed while a // selection operation is in progress // ## Throw an error if this channel has not been pre-closed return false ; } if ( ( ops & ( PollArrayWrapper . POLLERR | PollArrayWrapper . POLLHUP ) ) != 0 ) { newOps = intOps ; sk . nioReadyOps ( newOps ) ; // No need to poll again in checkConnect, // the error will be detected there readyToConnect = true ; return ( newOps & ~ oldOps ) != 0 ; } if ( ( ( ops & PollArrayWrapper . POLLIN ) != 0 ) && ( ( intOps & SelectionKey . OP_READ ) != 0 ) && ( state == ST_CONNECTED ) ) newOps |= SelectionKey . OP_READ ; if ( ( ( ops & PollArrayWrapper . POLLCONN ) != 0 ) && ( ( intOps & SelectionKey . OP_CONNECT ) != 0 ) && ( ( state == ST_UNCONNECTED ) || ( state == ST_PENDING ) ) ) { newOps |= SelectionKey . OP_CONNECT ; readyToConnect = true ; } if ( ( ( ops & PollArrayWrapper . POLLOUT ) != 0 ) && ( ( intOps & SelectionKey . OP_WRITE ) != 0 ) && ( state == ST_CONNECTED ) ) newOps |= SelectionKey . OP_WRITE ; sk . nioReadyOps ( newOps ) ; return ( newOps & ~ oldOps ) != 0 ; }
Translates native poll revent ops into a ready operation ops