源码分析
Java · 33 篇笔记
- 2.56 1.创建NioEventLoopGrouphistorical
NioEventLoopGroup 管理多个 NioEventLoop,可以接收 Runnable 任务。笔记从构造过程开始,追踪线程组如何创建。
- 2.57 2.Bootstrap的创建historical
创建 ServerBootstrap 后,还需要设置 Channel、Handler 和相关选项。笔记重点追踪 Channel 类型如何配置。
- 2.60 pipeline的初始化historical
每个 Netty Channel 都有自己的 Pipeline,在 AbstractChannel 构造时创建。笔记继续查看 Pipeline 的初始化方式。
- 2.65 2.创建NioSocketChannelhistorical
Netty 接收 Java NIO 的客户端连接后,把它包装为 NioSocketChannel。笔记追踪这个对象及父类的构造过程。
- 2.66 添加删除ChannelHandlerhistorical
本文从 DefaultChannelPipeline 的 addLast 等方法开始,追踪 ChannelHandler 的添加、检查和删除过程。
- 2.74 4.向selector注册读事件historical
Channel 注册完成后,需要向 Selector 注册读事件。笔记沿 AbstractChannel 的 register 操作追踪这一过程。
- 2.86 2.初始化channelhistorical
Channel 初始化时会向 Pipeline 添加 ChannelInitializer,再把 ServerBootstrap 中配置的 Handler 接入处理链。
- 2.97 PooledByteBufAllocatorhistorical
PooledByteBufAllocator 先获取线程缓存和对应的 PoolArena,再通过 PoolArena 分配内存。笔记沿这两个阶段追踪实现。
- 2.98 PoolThreadCachehistorical
PoolThreadCache 为不同大小的内存区域创建缓存。笔记查看 tiny、small 和 normal 三类 MemoryRegionCache 的初始化。