protected void invokeCallbacks ( ThreadLocalRandom r ) { final Set < SelectionKey > selectedKeys = m_selector . selectedKeys ( ) ; final int keyCount = selectedKeys . size ( ) ; int startInx = r . nextInt ( keyCount ) ; int itInx = 0 ; Iterator < SelectionKey > it = selectedKeys . iterator ( ) ; while ( itInx < startInx ) { it . next ( ) ; itInx ++ ; } while ( itInx < keyCount ) { final Object obj = it . next ( ) . attachment ( ) ; if ( obj == null ) { continue ; } final VoltPort port = ( VoltPort ) obj ; callPort ( port ) ; itInx ++ ; } itInx = 0 ; it = selectedKeys . iterator ( ) ; while ( itInx < startInx ) { final Object obj = it . next ( ) . attachment ( ) ; if ( obj == null ) { continue ; } final VoltPort port = ( VoltPort ) obj ; callPort ( port ) ; itInx ++ ; } selectedKeys . clear ( ) ; }
Set the selected interest set on the port and run it .