/** * <p> * Decrement the reference count of this object. * </p><p> * An object is asynchronously disposed once all references are * released. Using a disposed object will cause undefined errors. * The system does not guarantee that a given client is the last or * only reference to a given object. * </p> */ final public void release() { if( TRACE ) { synchronized(traces) { assertRetained(); final int x = retained.decrementAndGet(); trace("released", x); if (x == 0) { dispose(); trace("disposed", x); } } } else { assertRetained(); if (retained.decrementAndGet() == 0) { dispose(); } } }
/** * <p> * Decrements the reference count by n. * </p><p> * An object is asynchronously disposed once all references are * released. Using a disposed object will cause undefined errors. * The system does not guarantee that a given client is the last or * only reference to a given object. * </p> * @param n */ final protected void release(int n) { if( TRACE ) { synchronized(traces) { assertRetained(); int x = retained.addAndGet(-n); trace("released "+n, x); if ( x == 0) { trace("disposed", x); dispose(); } } } else { assertRetained(); if (retained.addAndGet(-n) == 0) { dispose(); } } }