public class ScheduledCloseable extends java.lang.Object implements java.io.Closeable, Cancelable
The implementation is thread-safe.
| Modifier and Type | Field and Description |
|---|---|
protected java.util.concurrent.atomic.AtomicReference<java.io.Closeable> |
current
The handle reference.
|
protected Scheduler |
scheduler
The scheduler reference.
|
protected static java.io.Closeable |
SENTINEL
The empty sentinel to know when we have
closed the previous instance and keep the
invariants of this SingleCloseable.
|
| Constructor and Description |
|---|
ScheduledCloseable(Scheduler scheduler,
java.io.Closeable handle)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
java.io.Closeable |
get() |
boolean |
isClosed() |
Scheduler |
scheduler() |
@Nonnull protected final Scheduler scheduler
@Nonnull protected final java.util.concurrent.atomic.AtomicReference<java.io.Closeable> current
@Nonnull protected static final java.io.Closeable SENTINEL
public ScheduledCloseable(@Nonnull
Scheduler scheduler,
@Nonnull
java.io.Closeable handle)
scheduler - the scheduler to usehandle - the handle to closepublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOException@Nonnull public Scheduler scheduler()
@Nonnull public java.io.Closeable get()
public boolean isClosed()
isClosed in interface Cancelable