ReferenceCountUtil Class — netty Architecture
Architecture documentation for the ReferenceCountUtil class in ReferenceCountUtil.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 2daf981a_8651_ffc2_96b7_bacfdd2d4972["ReferenceCountUtil"] 4ae0e714_0e2c_09d9_d699_7371b5bf44e4["ReferenceCountUtil.java"] 2daf981a_8651_ffc2_96b7_bacfdd2d4972 -->|defined in| 4ae0e714_0e2c_09d9_d699_7371b5bf44e4 5d278798_9314_decd_8b71_e17747cb1787["T()"] 2daf981a_8651_ffc2_96b7_bacfdd2d4972 -->|method| 5d278798_9314_decd_8b71_e17747cb1787 8c9dbc61_425f_a257_a014_3a33434e1f11["release()"] 2daf981a_8651_ffc2_96b7_bacfdd2d4972 -->|method| 8c9dbc61_425f_a257_a014_3a33434e1f11 8dac4c81_d894_c374_20a4_f122c66e2b39["safeRelease()"] 2daf981a_8651_ffc2_96b7_bacfdd2d4972 -->|method| 8dac4c81_d894_c374_20a4_f122c66e2b39 737c600b_c966_5262_9244_b78b9063cfcc["refCnt()"] 2daf981a_8651_ffc2_96b7_bacfdd2d4972 -->|method| 737c600b_c966_5262_9244_b78b9063cfcc e26a2f53_95ca_6186_c99d_7cc0381efa5c["ReferenceCountUtil()"] 2daf981a_8651_ffc2_96b7_bacfdd2d4972 -->|method| e26a2f53_95ca_6186_c99d_7cc0381efa5c
Relationship Graph
Source Code
common/src/main/java/io/netty/util/ReferenceCountUtil.java lines 26–209
public final class ReferenceCountUtil {
private static final InternalLogger logger = InternalLoggerFactory.getInstance(ReferenceCountUtil.class);
static {
ResourceLeakDetector.addExclusions(ReferenceCountUtil.class, "touch");
}
/**
* Try to call {@link ReferenceCounted#retain()} if the specified message implements {@link ReferenceCounted}.
* If the specified message doesn't implement {@link ReferenceCounted}, this method does nothing.
*/
@SuppressWarnings("unchecked")
public static <T> T retain(T msg) {
if (msg instanceof ReferenceCounted) {
return (T) ((ReferenceCounted) msg).retain();
}
return msg;
}
/**
* Try to call {@link ReferenceCounted#retain(int)} if the specified message implements {@link ReferenceCounted}.
* If the specified message doesn't implement {@link ReferenceCounted}, this method does nothing.
*/
@SuppressWarnings("unchecked")
public static <T> T retain(T msg, int increment) {
ObjectUtil.checkPositive(increment, "increment");
if (msg instanceof ReferenceCounted) {
return (T) ((ReferenceCounted) msg).retain(increment);
}
return msg;
}
/**
* Tries to call {@link ReferenceCounted#touch()} if the specified message implements {@link ReferenceCounted}.
* If the specified message doesn't implement {@link ReferenceCounted}, this method does nothing.
*/
@SuppressWarnings("unchecked")
public static <T> T touch(T msg) {
if (msg instanceof ReferenceCounted) {
return (T) ((ReferenceCounted) msg).touch();
}
return msg;
}
/**
* Tries to call {@link ReferenceCounted#touch(Object)} if the specified message implements
* {@link ReferenceCounted}. If the specified message doesn't implement {@link ReferenceCounted},
* this method does nothing.
*/
@SuppressWarnings("unchecked")
public static <T> T touch(T msg, Object hint) {
if (msg instanceof ReferenceCounted) {
return (T) ((ReferenceCounted) msg).touch(hint);
}
return msg;
}
/**
* Try to call {@link ReferenceCounted#release()} if the specified message implements {@link ReferenceCounted}.
* If the specified message doesn't implement {@link ReferenceCounted}, this method does nothing.
*/
public static boolean release(Object msg) {
if (msg instanceof ReferenceCounted) {
return ((ReferenceCounted) msg).release();
}
return false;
}
/**
* Try to call {@link ReferenceCounted#release(int)} if the specified message implements {@link ReferenceCounted}.
* If the specified message doesn't implement {@link ReferenceCounted}, this method does nothing.
*/
public static boolean release(Object msg, int decrement) {
ObjectUtil.checkPositive(decrement, "decrement");
if (msg instanceof ReferenceCounted) {
return ((ReferenceCounted) msg).release(decrement);
}
return false;
}
Source
Frequently Asked Questions
What is the ReferenceCountUtil class?
ReferenceCountUtil is a class in the netty codebase, defined in common/src/main/java/io/netty/util/ReferenceCountUtil.java.
Where is ReferenceCountUtil defined?
ReferenceCountUtil is defined in common/src/main/java/io/netty/util/ReferenceCountUtil.java at line 26.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free