Netty 4.0 源碼分析(六):EventLoop和EventLoopGroup
EventLoop相當(dāng)于一個(gè)Thread線程,而EventLoopGroup則是管理這些EventLoop的Thread線程池
EventLoop接口
package io.netty.channel;
public interface EventLoop extends EventExecutor, EventLoopGroup {
@Override
EventLoopGroup parent();
}
public interface EventLoop extends EventExecutor, EventLoopGroup {
@Override
EventLoopGroup parent();
}
EventLoop接口UML圖
parent()方法
返回管理這個(gè)EventLoop的EventLoopGroup。
EventLoopGroup接口
package io.netty.channel;
public interface EventLoopGroup extends EventExecutorGroup {
@Override
EventLoop next();
ChannelFuture register(Channel channel);
ChannelFuture register(Channel channel, ChannelFuture future);
}
public interface EventLoopGroup extends EventExecutorGroup {
@Override
EventLoop next();
ChannelFuture register(Channel channel);
ChannelFuture register(Channel channel, ChannelFuture future);
}
EventLoopGroup接口UML圖
next()
返回下一個(gè)EventLoop
register(Channel channel)
指定一個(gè)EventLoopGroup來(lái)注冊(cè)某個(gè)Channel。
備注:因?yàn)楣P者開(kāi)始寫Netty源碼分析的時(shí)候,Netty 4.0還是處于Alpha階段,之后的API可能還會(huì)有改動(dòng),筆者將會(huì)及時(shí)更改。使用開(kāi)源已經(jīng)有好幾年的時(shí)間了,一直沒(méi)有時(shí)間和精力來(lái)具體研究某個(gè)開(kāi)源項(xiàng)目的具體實(shí)現(xiàn),這次是第一次寫開(kāi)源項(xiàng)目的源碼分析,如果文中有錯(cuò)誤的地方,歡迎讀者可以留言指出。對(duì)于轉(zhuǎn)載的讀者,請(qǐng)注明文章的出處。
希望和廣大的開(kāi)發(fā)者/開(kāi)源愛(ài)好者進(jìn)行交流,歡迎大家的留言和討論。
-----------------------------------------------------
Silence, the way to avoid many problems;
Smile, the way to solve many problems;
posted on 2012-11-25 21:49 Chan Chen 閱讀(4508) 評(píng)論(0) 編輯 收藏 所屬分類: Netty