public final class ReferenceCountUtil
extends java.lang.Object
ReferenceCounted
.Modifier and Type | Class and Description |
---|---|
private static class |
ReferenceCountUtil.ReleasingTask
Releases the objects when the thread that called
releaseLater(Object) has been terminated. |
Modifier and Type | Field and Description |
---|---|
private static InternalLogger |
logger |
Modifier | Constructor and Description |
---|---|
private |
ReferenceCountUtil() |
Modifier and Type | Method and Description |
---|---|
static boolean |
release(java.lang.Object msg)
Try to call
ReferenceCounted.release() if the specified message implements ReferenceCounted . |
static boolean |
release(java.lang.Object msg,
int decrement)
Try to call
ReferenceCounted.release(int) if the specified message implements ReferenceCounted . |
static <T> T |
releaseLater(T msg)
Schedules the specified object to be released when the caller thread terminates.
|
static <T> T |
releaseLater(T msg,
int decrement)
Schedules the specified object to be released when the caller thread terminates.
|
static <T> T |
retain(T msg)
Try to call
ReferenceCounted.retain() if the specified message implements ReferenceCounted . |
static <T> T |
retain(T msg,
int increment)
Try to call
ReferenceCounted.retain() if the specified message implements ReferenceCounted . |
static void |
safeRelease(java.lang.Object msg)
Try to call
ReferenceCounted.release() if the specified message implements ReferenceCounted . |
static void |
safeRelease(java.lang.Object msg,
int decrement)
Try to call
ReferenceCounted.release(int) if the specified message implements ReferenceCounted . |
private static final InternalLogger logger
public static <T> T retain(T msg)
ReferenceCounted.retain()
if the specified message implements ReferenceCounted
.
If the specified message doesn't implement ReferenceCounted
, this method does nothing.public static <T> T retain(T msg, int increment)
ReferenceCounted.retain()
if the specified message implements ReferenceCounted
.
If the specified message doesn't implement ReferenceCounted
, this method does nothing.public static boolean release(java.lang.Object msg)
ReferenceCounted.release()
if the specified message implements ReferenceCounted
.
If the specified message doesn't implement ReferenceCounted
, this method does nothing.public static boolean release(java.lang.Object msg, int decrement)
ReferenceCounted.release(int)
if the specified message implements ReferenceCounted
.
If the specified message doesn't implement ReferenceCounted
, this method does nothing.public static void safeRelease(java.lang.Object msg)
ReferenceCounted.release()
if the specified message implements ReferenceCounted
.
If the specified message doesn't implement ReferenceCounted
, this method does nothing.
Unlike release(Object)
this method catches an exception raised by ReferenceCounted.release()
and logs it, rather than rethrowing it to the caller. It is usually recommended to use release(Object)
instead, unless you absolutely need to swallow an exception.public static void safeRelease(java.lang.Object msg, int decrement)
ReferenceCounted.release(int)
if the specified message implements ReferenceCounted
.
If the specified message doesn't implement ReferenceCounted
, this method does nothing.
Unlike release(Object)
this method catches an exception raised by ReferenceCounted.release(int)
and logs it, rather than rethrowing it to the caller. It is usually recommended to use
release(Object, int)
instead, unless you absolutely need to swallow an exception.public static <T> T releaseLater(T msg)
public static <T> T releaseLater(T msg, int decrement)