Package com.google.common.jimfs
Class JimfsAsynchronousFileChannel
- java.lang.Object
-
- java.nio.channels.AsynchronousFileChannel
-
- com.google.common.jimfs.JimfsAsynchronousFileChannel
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.nio.channels.AsynchronousChannel
,java.nio.channels.Channel
final class JimfsAsynchronousFileChannel extends java.nio.channels.AsynchronousFileChannel
AsynchronousFileChannel
implementation that delegates to aJimfsFileChannel
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
JimfsAsynchronousFileChannel.CompletionHandlerCallback<R,A>
Runnable callback that wraps aCompletionHandler
and an attachment.
-
Field Summary
Fields Modifier and Type Field Description private JimfsFileChannel
channel
private com.google.common.util.concurrent.ListeningExecutorService
executor
-
Constructor Summary
Constructors Constructor Description JimfsAsynchronousFileChannel(JimfsFileChannel channel, java.util.concurrent.ExecutorService executor)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private <R,A>
voidaddCallback(com.google.common.util.concurrent.ListenableFuture<R> future, java.nio.channels.CompletionHandler<R,? super A> handler, @Nullable A attachment)
void
close()
private static <V> com.google.common.util.concurrent.ListenableFuture<V>
closedChannelFuture()
Immediate future indicating that the channel is closed.void
force(boolean metaData)
boolean
isOpen()
com.google.common.util.concurrent.ListenableFuture<java.nio.channels.FileLock>
lock(long position, long size, boolean shared)
<A> void
lock(long position, long size, boolean shared, @Nullable A attachment, java.nio.channels.CompletionHandler<java.nio.channels.FileLock,? super A> handler)
com.google.common.util.concurrent.ListenableFuture<java.lang.Integer>
read(java.nio.ByteBuffer dst, long position)
<A> void
read(java.nio.ByteBuffer dst, long position, @Nullable A attachment, java.nio.channels.CompletionHandler<java.lang.Integer,? super A> handler)
long
size()
java.nio.channels.AsynchronousFileChannel
truncate(long size)
java.nio.channels.FileLock
tryLock(long position, long size, boolean shared)
com.google.common.util.concurrent.ListenableFuture<java.lang.Integer>
write(java.nio.ByteBuffer src, long position)
<A> void
write(java.nio.ByteBuffer src, long position, @Nullable A attachment, java.nio.channels.CompletionHandler<java.lang.Integer,? super A> handler)
-
-
-
Field Detail
-
channel
private final JimfsFileChannel channel
-
executor
private final com.google.common.util.concurrent.ListeningExecutorService executor
-
-
Constructor Detail
-
JimfsAsynchronousFileChannel
public JimfsAsynchronousFileChannel(JimfsFileChannel channel, java.util.concurrent.ExecutorService executor)
-
-
Method Detail
-
size
public long size() throws java.io.IOException
- Specified by:
size
in classjava.nio.channels.AsynchronousFileChannel
- Throws:
java.io.IOException
-
addCallback
private <R,A> void addCallback(com.google.common.util.concurrent.ListenableFuture<R> future, java.nio.channels.CompletionHandler<R,? super A> handler, @Nullable A attachment)
-
truncate
@CanIgnoreReturnValue public java.nio.channels.AsynchronousFileChannel truncate(long size) throws java.io.IOException
- Specified by:
truncate
in classjava.nio.channels.AsynchronousFileChannel
- Throws:
java.io.IOException
-
force
public void force(boolean metaData) throws java.io.IOException
- Specified by:
force
in classjava.nio.channels.AsynchronousFileChannel
- Throws:
java.io.IOException
-
lock
public <A> void lock(long position, long size, boolean shared, @Nullable A attachment, java.nio.channels.CompletionHandler<java.nio.channels.FileLock,? super A> handler)
- Specified by:
lock
in classjava.nio.channels.AsynchronousFileChannel
-
lock
public com.google.common.util.concurrent.ListenableFuture<java.nio.channels.FileLock> lock(long position, long size, boolean shared)
- Specified by:
lock
in classjava.nio.channels.AsynchronousFileChannel
-
tryLock
public java.nio.channels.FileLock tryLock(long position, long size, boolean shared) throws java.io.IOException
- Specified by:
tryLock
in classjava.nio.channels.AsynchronousFileChannel
- Throws:
java.io.IOException
-
read
public <A> void read(java.nio.ByteBuffer dst, long position, @Nullable A attachment, java.nio.channels.CompletionHandler<java.lang.Integer,? super A> handler)
- Specified by:
read
in classjava.nio.channels.AsynchronousFileChannel
-
read
public com.google.common.util.concurrent.ListenableFuture<java.lang.Integer> read(java.nio.ByteBuffer dst, long position)
- Specified by:
read
in classjava.nio.channels.AsynchronousFileChannel
-
write
public <A> void write(java.nio.ByteBuffer src, long position, @Nullable A attachment, java.nio.channels.CompletionHandler<java.lang.Integer,? super A> handler)
- Specified by:
write
in classjava.nio.channels.AsynchronousFileChannel
-
write
public com.google.common.util.concurrent.ListenableFuture<java.lang.Integer> write(java.nio.ByteBuffer src, long position)
- Specified by:
write
in classjava.nio.channels.AsynchronousFileChannel
-
isOpen
public boolean isOpen()
-
close
public void close() throws java.io.IOException
- Throws:
java.io.IOException
-
closedChannelFuture
private static <V> com.google.common.util.concurrent.ListenableFuture<V> closedChannelFuture()
Immediate future indicating that the channel is closed.
-
-