Esempio n. 1
0
 private void processEventQueue() throws IOException {
   for (; ; ) {
     final Runnable task = eventQueue.poll();
     if (task == null) {
       break;
     }
     task.run();
     cleanUpCancelledKeys();
   }
 }
    private void processRegisterTaskQueue() {
      for (; ; ) {
        final Runnable task = registerTaskQueue.poll();
        if (task == null) {
          break;
        }

        task.run();
      }
    }
Esempio n. 3
0
  @Override
  public ChannelFuture executeInIoThread(Channel channel, Runnable task) {
    if (channel instanceof SctpChannelImpl && isIoThread((SctpChannelImpl) channel)) {
      try {
        task.run();
        return succeededFuture(channel);
      } catch (Throwable t) {
        return failedFuture(channel, t);
      }
    } else {
      ChannelRunnableWrapper channelRunnable = new ChannelRunnableWrapper(channel, task);
      boolean added = eventQueue.offer(channelRunnable);

      if (added) {
        // wake up the selector to speed things
        selector.wakeup();
      } else {
        channelRunnable.setFailure(new RejectedExecutionException("Unable to queue task " + task));
      }
      return channelRunnable;
    }
  }