Code example for SelectionKey

Methods: cancel

0
        state_ = FrameBufferState.WRITING;
      } else if (state_ == FrameBufferState.AWAITING_REGISTER_READ) {
        prepareRead(); 
      } else if (state_ == FrameBufferState.AWAITING_CLOSE) {
        close(); 
        selectionKey_.cancel();
      } else { 
        Log.e("Thrift", "changeSelectInterest was called, but state is invalid (" + state_ + ")");
      } 
    } 
 
    /** 
     * Shut the connection down. 
     */ 
    public void close() { 
      // if we're being closed due to an error, we might have allocated a 
      // buffer that we need to subtract for our memory accounting. 
      if (state_ == FrameBufferState.READING_FRAME || state_ == FrameBufferState.READ_FRAME_COMPLETE) {
        readBufferBytesAllocated.addAndGet(-buffer_.array().length);
      }