public interface AutoDisposable extends Disposable
Disposable
that keeps track of references to it and disposes the
object automatically when there are no references left. At creation time an AutoDisposable
has zero reference count so whenever same number of release()
calls follows acquire()
calls, it will be automatically closed. Calling Disposable.dispose()
directly will dispose the object
immediately regardless of the reference count.Modifier and Type | Method and Description |
---|---|
<T extends AutoDisposable> |
acquire()
Acquires a reference to this object preventing it from being automatically disposed until the
reference is released.
|
int |
getRefCount()
Return the current reference count for this object.
|
void |
release()
Releases one of these object's references.
|
<T extends AutoDisposable> |
tryAcquire()
Tries to acquire a reference to this object.
|
dispose
<T extends AutoDisposable> T acquire()
T
- <T extends AutoDisposable> T tryAcquire()
null
is returned instead.
Note: this method should be used after the object has been acquired
for the first time. Before that it always returns null
. The common use case is that the first acquire()
happens before the object is published and becomes visible to users.T
- object typevoid release()
int getRefCount()
Copyright © 2010-2016 Stardog Union. All Rights Reserved.