netty 主要逻辑
2024-04-06 11:41:21 0 举报
登录查看完整内容
netty 主要逻辑
作者其他创作
大纲/内容
默认逻辑核心数*2
使用Jctools提供的队列,没有锁
channel每一个链接一个
DefaultChannelPipeline#fireChannelRegistered调用所有注册的handler的方法
NioEventLoop#newTaskQueue()
AbstractChannel#bind
把配置的 ChannelHandler 添加到 ChannelPipeline
MultithreadEventExecutorGroup#MultithreadEventExecutorGroup最终会到这个构造器
AbstractNioChannel#doRegister
AbstractChannelHandlerContext#invokeBind调用不同的实现绑定端口
ChannelPipeline#fireChannelRead从头开始调用 handler
AbstractBootstrap#doBind0
ServerBootstrapAcceptor#channelRead有新的数据过来了
AbstractChannel.AbstractUnsafe#register
NioSocketChannel创建一个channel
SelectableChannel#register调用Java的NIO接口
Selector#selectedKeys获取活动的key
NioEventLoop#processSelectedKey
ServerBootstrap#init初始化channel
AbstractBootstrap#bind前面配置完后都要调用
AbstractBootstrap#doBind
SingleThreadEventLoop#register
ServerBootstrapAcceptor添加到bossEventLoopGroup的Handler中
AbstractChannelHandlerContext#bind
EventExecutor[] children初始化事件执行器数组默认是逻辑核数*2
NioEventLoop#NioEventLoop
Selector#selectNow()获取活动的key的数量
NioEventLoop#processSelectedKeysPlain
读取缓冲区的数据
EventLoopGroup
MpscUnboundedArrayQueue创建一个多生产者单消费者的队列
NioEventLoopGroupnew出一个group
NioEventLoopGroup#newChild
NioEventLoop#run
AbstractChannel.AbstractUnsafe#register0
AbstractNioByteChannel.NioByteUnsafe#read
AbstractBootstrap#initAndRegister
NioEventLoop#newTaskQueue0
EventLoop一个对应一个线程
childGroup.register(child)把当前的channel注册到work线程组里面
0 条评论
回复 删除
下一页