課程
/后端開發(fā)
/Java
/Netty入門之WebSocket初體驗(yàn)
frame.retain() 是什么意思,查了一下和引用計(jì)數(shù)有關(guān),引用計(jì)數(shù)是什么東西啊
2019-08-28
源自:Netty入門之WebSocket初體驗(yàn) 5-4
正在回答
類的關(guān)系:?frame是個(gè)?WebSocketFrame? public?abstract?class?WebSocketFrame?extends?DefaultByteBufHolder? 而WebSocketFrame?實(shí)現(xiàn): public?class?DefaultByteBufHolder?implements?ByteBufHolder?{ ????private?final?ByteBuf?data; ????public?DefaultByteBufHolder(ByteBuf?data)?{ ????????if?(data?==?null)?{ ????????????throw?new?NullPointerException("data"); ????????}?else?{ ????????????this.data?=?data; ????????} ????} ????public?ByteBuf?content()?{ ????????if?(this.data.refCnt()?<=?0)?{ ????????????throw?new?IllegalReferenceCountException(this.data.refCnt()); ????????}?else?{ ????????????return?this.data; ????????} ????} ????public?ByteBufHolder?copy()?{ ????????return?new?DefaultByteBufHolder(this.data.copy()); ????} ????public?ByteBufHolder?duplicate()?{ ????????return?new?DefaultByteBufHolder(this.data.duplicate()); ????} ????public?int?refCnt()?{ ????????return?this.data.refCnt(); ????} ????public?ByteBufHolder?retain()?{ ????????this.data.retain(); ????????return?this; ????} ????public?ByteBufHolder?retain(int?increment)?{ ????????this.data.retain(increment); ????????return?this; ????} ????public?boolean?release()?{ ????????return?this.data.release(); ????} ????public?boolean?release(int?decrement)?{ ????????return?this.data.release(decrement); ????} ????public?String?toString()?{ ????????return?StringUtil.simpleClassName(this)?+?'('?+?this.content().toString()?+?')'; ????} }
前一次回答里2個(gè)類名標(biāo)注了粗體字,不知何故類名都不見了。
類的關(guān)系: public?abstract?class??extends?DefaultByteBufHolder
public?class??implements?ByteBufHolder?{ ????private?final?ByteBuf?data; ????public?DefaultByteBufHolder(ByteBuf?data)?{ ????????if?(data?==?null)?{ ????????????throw?new?NullPointerException("data"); ????????}?else?{ ????????????this.data?=?data; ????????} ????} ????public?ByteBuf?content()?{ ????????if?(this.data.refCnt()?<=?0)?{ ????????????throw?new?IllegalReferenceCountException(this.data.refCnt()); ????????}?else?{ ????????????return?this.data; ????????} ????} ????public?ByteBufHolder?copy()?{ ????????return?new?DefaultByteBufHolder(this.data.copy()); ????} ????public?ByteBufHolder?duplicate()?{ ????????return?new?DefaultByteBufHolder(this.data.duplicate()); ????} ????public?int?refCnt()?{ ????????return?this.data.refCnt(); ????} ????public?ByteBufHolder??{ ????????this.data.retain(); ????????return?this; ????} ????public?ByteBufHolder?retain(int?increment)?{ ????????this.data.retain(increment); ????????return?this; ????} ????public?boolean?release()?{ ????????return?this.data.release(); ????} ????public?boolean?release(int?decrement)?{ ????????return?this.data.release(decrement); ????} ????public?String?toString()?{ ????????return?StringUtil.simpleClassName(this)?+?'('?+?this.content().toString()?+?')'; ????} }
abstract?ByteBuf
retain()
Increases the reference count by?1.
1
舉報(bào)
由淺入深了解Java高性能NIO通信首選框架——Netty
1 回答請(qǐng)問老師 這個(gè)錯(cuò)誤是什么原因?
4 回答netty是異步非阻塞??不是同步非阻塞么?
1 回答為什么不創(chuàng)建maven項(xiàng)目呢?
2 回答WebSocketServerProtocolHandler不是處理http升級(jí)websocket,還有心跳的嗎,怎么還要自己再寫處理http請(qǐng)求的邏輯呢,那WebSocketServerProtocolHandler到底起了什么作用呢
1 回答?既然netty是基于nio的網(wǎng)路通信框架,為社么不是同步非阻塞,而是異步非阻塞呢?
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2019-10-17
前一次回答里2個(gè)類名標(biāo)注了粗體字,不知何故類名都不見了。
2019-10-17
abstract?ByteBuf
retain()
Increases the reference count by?
1
.