public class RefCountCloseable extends java.lang.Object implements java.io.Closeable, Cancelable
Can be used in cases where one has to wait for all work items to complete before closing the main handle.
| Modifier and Type | Class and Description |
|---|---|
protected static class |
RefCountCloseable.InnerCloseable
The dependent closeable implementation.
|
| Modifier and Type | Field and Description |
|---|---|
protected java.io.Closeable |
closeable
The closeable to close when all dependent closeables are closed.
|
protected int |
count
The number of open dependent closeables.
|
protected java.util.concurrent.locks.Lock |
lock
The lock guarding the internal variables.
|
protected boolean |
primaryClosed
Indicate that the primary handle is closed already.
|
| Constructor and Description |
|---|
RefCountCloseable(java.io.Closeable closeable)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
java.io.Closeable |
getCloseable()
Returns a new dependent closeable instance.
|
boolean |
isClosed() |
protected void |
release()
Releases an dependent closeable.
|
protected final java.util.concurrent.locks.Lock lock
protected java.io.Closeable closeable
protected boolean primaryClosed
protected int count
public RefCountCloseable(@Nonnull
java.io.Closeable closeable)
closeable - the closeable to managepublic boolean isClosed()
isClosed in interface Cancelablepublic java.io.Closeable getCloseable()
public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOExceptionprotected void release()
throws java.io.IOException
java.io.IOException - the propagated close exception