https://juejin.im/post/6844903712435994631#heading-12

    架构设计 - 图1

    模块组件:

    • Bootstrap、ServerBootstrap
    • Future、ChannelFuture
    • Channel
    • Selector
    • NioEventLoop
    • NioEventLoopGroup:bossGroup、workerGroup
    • ChannelHandler
    • ChannelHandlerContext
    • ChannelPipline

    架构设计 - 图2

    runAllTasks:

    • 用户自己提交到线程池的任务,调用 eventloop.execute() 或 schedule() 定时任务。
    • 或者其他线程提交的任务

    Boss NioEventLoop 循环执行的任务:

    1. 轮询 accept 事件
    2. 处理 accept IO 事件,与 Client 建立连接,生成 NioSocketChannel,并将 NioSocketChannel 注册到某个Worker NioEventLoopSelector
    3. runAllTasks

    Worker NioEventLoop 循环执行的任务:

    1. 轮询 read、write 事件
    2. 处理 read、write IO 事件,在 NioSocketChannel 可读可写事件发生时进行处理
    3. runAllTasks