V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
hellomsg
V2EX  ›  Java

谁能给我讲讲 netty 的 event loop 的原理

  •  
  •   hellomsg · 2015-03-10 18:01:15 +08:00 · 2625 次点击
    这是一个创建于 3341 天前的主题,其中的信息可能已经有所发展或是发生改变。

    谁能给我讲讲netty的event loop的原理。喷也好

    6 条回复    2015-05-29 18:48:49 +08:00
    hellomsg
        1
    hellomsg  
    OP
       2015-03-11 17:54:56 +08:00
    看来你们都不够坚挺啊,不行啊,不行啊
    zenliver
        2
    zenliver  
       2015-03-11 18:12:48 +08:00
    你在自言自语吗,,,应该大部分的event loop原理都差不多吧, 围绕select类函数展开,,,
    funky
        3
    funky  
       2015-03-13 18:22:27 +08:00
    LZ在自言自语么
    hellomsg
        4
    hellomsg  
    OP
       2015-03-13 22:41:34 +08:00 via iPad
    @funky 没人说话只能自言自语了
    tangdibupt
        5
    tangdibupt  
       2015-05-06 16:48:45 +08:00
    用SingleThreadEventLoop 举例吧,里面的event是存在一个BlockingLinkedQueue里面。eventloop具体的执行交给executor。
    每次executor执行一个任务时,他会执行 SingleThreadEventLoop.this.run()
    实际上这个runnable就是从BlockingLinkedQueue里取出一个task,执行task,然后重新call executor.execute(Runnable)。

    我觉得,不同的eventloop区别在于 存储task 和 take task的方式不同。epoll 有epoll的方式,nio有nio的方式。
    hepin1989
        6
    hepin1989  
       2015-05-29 18:48:49 +08:00
    又没给钱。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2140 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 11:49 · PVG 19:49 · LAX 04:49 · JFK 07:49
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.