public class TaggedCompositeCloseable extends java.lang.Object implements java.io.Closeable, Cancelable
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
done
Flag to indicate this item container is closed.
|
protected java.util.Map<java.lang.Object,java.io.Closeable> |
items
The sub-observer registration holder.
|
protected java.util.concurrent.locks.Lock |
lock
The lock protecting the inner structures.
|
| Constructor and Description |
|---|
TaggedCompositeCloseable()
Construct a new instance with a fair reentrant lock.
|
TaggedCompositeCloseable(java.util.concurrent.locks.Lock lock)
Constructs an instance with the given shared lock.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(java.lang.Object token,
java.io.Closeable c)
Adds or replaces a new closeable by the given token.
|
void |
close() |
void |
delete(java.lang.Object token)
Removes but does not close the given token
from this composite.
|
protected void |
init()
Initializes the items map.
|
boolean |
isClosed() |
void |
remove(java.lang.Object token)
Remove and close the closeable identified by the token.
|
protected final java.util.concurrent.locks.Lock lock
@Nonnull protected java.util.Map<java.lang.Object,java.io.Closeable> items
protected boolean done
public TaggedCompositeCloseable()
public TaggedCompositeCloseable(java.util.concurrent.locks.Lock lock)
lock - the lock to useprotected void init()
public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOExceptionpublic void add(@Nonnull
java.lang.Object token,
@Nonnull
java.io.Closeable c)
token - the token identifying the closeablec - the closeable instancepublic void remove(@Nonnull
java.lang.Object token)
token - the token to removepublic void delete(@Nonnull
java.lang.Object token)
token - the token identifying the closeablepublic boolean isClosed()
isClosed in interface Cancelable