示例#1
0
 /**
  * Stops the Reactor activity, including the Reactor thread and the Worker Threads in the Thread
  * Pool.
  */
 public synchronized void stopReactor() {
   if (!_shouldRun) return;
   _shouldRun = false;
   _data.getSelector().wakeup(); // Force select() to return
   _data.getExecutor().shutdown();
   try {
     _data.getExecutor().awaitTermination(2000, TimeUnit.MILLISECONDS);
   } catch (InterruptedException e) {
     // Someone didn't have patience to wait for the executor pool to
     // close
     e.printStackTrace();
   }
 }
 /**
  * switches the handler to write only mode
  *
  * @throws ClosedChannelException if the channel is closed
  */
 public void switchToWriteOnlyMode() {
   _skey.interestOps(SelectionKey.OP_WRITE);
   _data.getSelector().wakeup();
 }
 /**
  * switches the handler to read only mode
  *
  * @throws ClosedChannelException if the channel is closed
  */
 public void switchToReadOnlyMode() {
   _skey.interestOps(SelectionKey.OP_READ);
   _data.getSelector().wakeup();
 }
 /**
  * switches the handler to read / write TODO Auto-generated catch blockmode
  *
  * @throws ClosedChannelException if the channel is closed
  */
 public void switchToReadWriteMode() {
   _skey.interestOps(SelectionKey.OP_READ | SelectionKey.OP_WRITE);
   _data.getSelector().wakeup();
 }