Package org.terracotta.offheapstore.util
Class ReopeningInterruptibleChannel<T extends java.nio.channels.InterruptibleChannel>
- java.lang.Object
-
- org.terracotta.offheapstore.util.ReopeningInterruptibleChannel<T>
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,java.nio.channels.Channel,java.nio.channels.InterruptibleChannel
public final class ReopeningInterruptibleChannel<T extends java.nio.channels.InterruptibleChannel> extends java.lang.Object implements java.nio.channels.InterruptibleChannel
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceReopeningInterruptibleChannel.IoOperation<T,R>
-
Field Summary
Fields Modifier and Type Field Description private java.util.function.Supplier<T>channelFactoryprivate java.util.concurrent.atomic.AtomicReference<T>currentChannelprivate static org.slf4j.LoggerLOGGER
-
Constructor Summary
Constructors Modifier Constructor Description privateReopeningInterruptibleChannel(java.util.function.Supplier<T> deviceFactory)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()static <T extends java.nio.channels.InterruptibleChannel>
ReopeningInterruptibleChannel<T>create(java.util.function.Supplier<T> channelFactory)<R> Rexecute(ReopeningInterruptibleChannel.IoOperation<T,R> operation)booleanisOpen()
-
-
-
Field Detail
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
channelFactory
private final java.util.function.Supplier<T extends java.nio.channels.InterruptibleChannel> channelFactory
-
currentChannel
private final java.util.concurrent.atomic.AtomicReference<T extends java.nio.channels.InterruptibleChannel> currentChannel
-
-
Constructor Detail
-
ReopeningInterruptibleChannel
private ReopeningInterruptibleChannel(java.util.function.Supplier<T> deviceFactory)
-
-
Method Detail
-
create
public static <T extends java.nio.channels.InterruptibleChannel> ReopeningInterruptibleChannel<T> create(java.util.function.Supplier<T> channelFactory)
-
execute
public <R> R execute(ReopeningInterruptibleChannel.IoOperation<T,R> operation) throws java.io.IOException
- Throws:
java.io.IOException
-
isOpen
public boolean isOpen()
- Specified by:
isOpenin interfacejava.nio.channels.Channel
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.nio.channels.Channel- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein interfacejava.nio.channels.InterruptibleChannel- Throws:
java.io.IOException
-
-