1.attribute允许存储一个值引用。它可以原子更新,因此它是线程安全的。
2.attribute是一个属性对象,这个属性的key为AttributeKey,属性的值T为value。
3.AttributeKey继承自AbstractConstant,因此也由ConstantPool创建。
4.Channel类本身继承了AttributeMap,而AttributeMap它持有多个Attribute,这些attribute可以通过attributekey来访问。channel.attr(key).set(value)
将属性值设置到channel中。
5.在Netty 4.1版本之后,ChannelHandlerContext
和Channel
的attr
方法设置的属性作用域已经完全相同了。
ChannelHandlerContext.attr() == Channel.attr()
。
Attribute AttributeKey与AttributeMap
最新推荐文章于 2024-04-12 00:53:25 发布