Java 类io.netty.util.concurrent.SingleThreadEventExecutor 实例源码

项目:netty4study    文件:LocalChannel.java   
@Override
protected void doRegister() throws Exception {
    if (peer != null) {
        state = 2;

        peer.remoteAddress = parent().localAddress();
        peer.state = 2;

        // Always call peer.eventLoop().execute() even if peer.eventLoop().inEventLoop() is true.
        // This ensures that if both channels are on the same event loop, the peer's channelActive
        // event is triggered *after* this channel's channelRegistered event, so that this channel's
        // pipeline is fully initialized by ChannelInitializer before any channelRead events.
        peer.eventLoop().execute(new Runnable() {
            @Override
            public void run() {
                peer.pipeline().fireChannelActive();
                peer.connectPromise.setSuccess();
            }
        });
    }
    ((SingleThreadEventExecutor) eventLoop()).addShutdownHook(shutdownHook);
}
项目:netty-netty-5.0.0.Alpha1    文件:LocalChannel.java   
@Override
protected void doRegister() throws Exception {
    if (peer != null) {
        state = State.CONNECTED;

        peer.remoteAddress = parent() == null ? null : parent().localAddress();
        peer.state = State.CONNECTED;

        // Always call peer.eventLoop().execute() even if peer.eventLoop().inEventLoop() is true.
        // This ensures that if both channels are on the same event loop, the peer's channelActive
        // event is triggered *after* this channel's channelRegistered event, so that this channel's
        // pipeline is fully initialized by ChannelInitializer before any channelRead events.
        peer.eventLoop().execute(new Runnable() {
            @Override
            public void run() {
                peer.pipeline().fireChannelActive();
                peer.connectPromise.setSuccess();
            }
        });
    }
    ((SingleThreadEventExecutor) eventLoop()).addShutdownHook(shutdownHook);
}
项目:gruffalo    文件:NettyQueuesMetricsInitializer.java   
public NettyQueuesMetricsInitializer(final MetricFactory metricFactory, final EventLoopGroup elg) {
  if (metricFactory == null || elg == null) {
    return;
  }

  int index = 0;
  for (final EventExecutor eventExecutor : elg) {
    if (eventExecutor instanceof SingleThreadEventExecutor) {
      final SingleThreadEventExecutor singleExecutor = (SingleThreadEventExecutor) eventExecutor;
      metricFactory.registerGauge("GruffaloEventLoopGroup", "EventLoop-" + index, new Gauge<Integer>() {
        @Override
        public Integer getValue() {
          return singleExecutor.pendingTasks();
        }
      });

      index++;
    }
  }
}
项目:netty4study    文件:LocalChannel.java   
@Override
protected void doDeregister() throws Exception {
    if (isOpen()) {
        unsafe().close(unsafe().voidPromise());
    }
    ((SingleThreadEventExecutor) eventLoop()).removeShutdownHook(shutdownHook);
}
项目:ob1k    文件:NettyQueuesGaugeBuilder.java   
public static void registerQueueGauges(final MetricFactory factory, final EventLoopGroup elg, final String componentName) {
  if (factory == null || elg == null) {
    return;
  }

  int index = 0;
  for (final EventExecutor eventExecutor : elg) {
    if (eventExecutor instanceof SingleThreadEventExecutor) {
      final SingleThreadEventExecutor singleExecutor = (SingleThreadEventExecutor) eventExecutor;
      factory.registerGauge("EventLoopGroup-" + componentName, "EventLoop-" + index, singleExecutor::pendingTasks);

      index++;
    }
  }
}
项目:netty4.0.27Learn    文件:LocalChannel.java   
@Override
protected void doDeregister() throws Exception {
    // Just remove the shutdownHook as this Channel may be closed later or registered to another EventLoop
    ((SingleThreadEventExecutor) eventLoop()).removeShutdownHook(shutdownHook);
}
项目:netty4.0.27Learn    文件:LocalServerChannel.java   
@Override
protected void doRegister() throws Exception {
    ((SingleThreadEventExecutor) eventLoop()).addShutdownHook(shutdownHook);
}
项目:netty4.0.27Learn    文件:LocalServerChannel.java   
@Override
protected void doDeregister() throws Exception {
    ((SingleThreadEventExecutor) eventLoop()).removeShutdownHook(shutdownHook);
}
项目:netty4study    文件:LocalServerChannel.java   
@Override
protected void doRegister() throws Exception {
    ((SingleThreadEventExecutor) eventLoop()).addShutdownHook(shutdownHook);
}
项目:netty4study    文件:LocalServerChannel.java   
@Override
protected void doDeregister() throws Exception {
    ((SingleThreadEventExecutor) eventLoop()).removeShutdownHook(shutdownHook);
}
项目:netty-netty-5.0.0.Alpha1    文件:LocalChannel.java   
@Override
protected void doDeregister() throws Exception {
    ((SingleThreadEventExecutor) eventLoop()).removeShutdownHook(shutdownHook);
}
项目:netty-netty-5.0.0.Alpha1    文件:LocalServerChannel.java   
@Override
protected void doRegister() throws Exception {
    ((SingleThreadEventExecutor) eventLoop()).addShutdownHook(shutdownHook);
}
项目:netty-netty-5.0.0.Alpha1    文件:LocalServerChannel.java   
@Override
protected void doDeregister() throws Exception {
    ((SingleThreadEventExecutor) eventLoop()).removeShutdownHook(shutdownHook);
}