Top Description Inners Fields Constructors Methods
sun.nio.ch

public Class SimpleAsynchronousFileChannelImpl

extends AsynchronousFileChannelImpl
Class Inheritance
Imports
jdk.internal.event.FileForceEvent, java.nio.channels.*, java.util.concurrent.*, java.nio.ByteBuffer, java.security.AccessController, .PrivilegedAction, java.io.FileDescriptor, .IOException

"Portable" implementation of AsynchronousFileChannel for use on operating systems that don't support asynchronous file I/O.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private static final FileDispatcher
private final String
private final NativeThreadSet
Inherited from sun.nio.ch.AsynchronousFileChannelImpl:
closedcloseLockexecutorfdObjreadingwriting

Constructor Summary

AccessConstructor and Description
pack-priv
SimpleAsynchronousFileChannelImpl(FileDescriptor fdObj, String path, boolean reading, boolean writing, ExecutorService executor)

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements java.nio.channels.AsynchronousChannel.close.

Closes this channel.

public void
force(boolean
If true then this method is required to force changes to both the file's content and metadata to be written to storage; otherwise, it need only force content changes to be written
metaData
)

Implements abstract java.nio.channels.AsynchronousFileChannel.force.

Forces any updates to this channel's file to be written to the storage device that contains it.

private void
implForce(boolean metaData)

pack-priv <A> Future<FileLock>
implLock(final long position, final long size, final boolean shared, final A attachment, final CompletionHandler<FileLock, ? super A> handler)

Implements abstract sun.nio.ch.AsynchronousFileChannelImpl.implLock.

pack-priv <A> Future<Integer>
implRead(final ByteBuffer dst, final long position, final A attachment, final CompletionHandler<Integer, ? super A> handler)

Implements abstract sun.nio.ch.AsynchronousFileChannelImpl.implRead.

protected void
implRelease(FileLockImpl fli)

Implements abstract sun.nio.ch.AsynchronousFileChannelImpl.implRelease.

Releases the given file lock.

pack-priv <A> Future<Integer>
implWrite(final ByteBuffer src, final long position, final A attachment, final CompletionHandler<Integer, ? super A> handler)

Implements abstract sun.nio.ch.AsynchronousFileChannelImpl.implWrite.

public static AsynchronousFileChannel
open(FileDescriptor fdo, String path, boolean reading, boolean writing, ThreadPool pool)

public long
size()

Implements abstract java.nio.channels.AsynchronousFileChannel.size.

Returns the current size of this channel's file.

public AsynchronousFileChannel
truncate(long
The new size, a non-negative byte count
size
)

Implements abstract java.nio.channels.AsynchronousFileChannel.truncate.

Truncates this channel's file to the given size.

public FileLock
tryLock(long
The position at which the locked region is to start; must be non-negative
position
,
long
The size of the locked region; must be non-negative, and the sum position + size must be non-negative. A value of zero means to lock all bytes from the specified starting position to the end of the file, regardless of whether the file is subsequently extended or truncated
size
,
boolean
true to request a shared lock, false to request an exclusive lock
shared
)

Implements abstract java.nio.channels.AsynchronousFileChannel.tryLock.

Attempts to acquire a lock on the given region of this channel's file.

Inherited from sun.nio.ch.AsynchronousFileChannelImpl:
addToFileLockTablebeginendendensureFileLockTableInitializedexecutorinvalidateAllLocksisOpenlocklockreadreadreleaseremoveFromFileLockTablewritewrite

Field Detail

ndback to summary
private static final FileDispatcher nd
pathback to summary
private final String path
threadsback to summary
private final NativeThreadSet threads

Constructor Detail

SimpleAsynchronousFileChannelImplback to summary
pack-priv SimpleAsynchronousFileChannelImpl(FileDescriptor fdObj, String path, boolean reading, boolean writing, ExecutorService executor)

Method Detail

closeback to summary
public void close() throws IOException

Implements java.nio.channels.AsynchronousChannel.close.

Doc from java.nio.channels.AsynchronousChannel.close.

Closes this channel.

Any outstanding asynchronous operations upon this channel will complete with the exception AsynchronousCloseException. After a channel is closed, further attempts to initiate asynchronous I/O operations complete immediately with cause ClosedChannelException.

This method otherwise behaves exactly as specified by the Channel interface.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
forceback to summary
public void force(boolean metaData) throws IOException

Implements abstract java.nio.channels.AsynchronousFileChannel.force.

Doc from java.nio.channels.AsynchronousFileChannel.force.

Forces any updates to this channel's file to be written to the storage device that contains it.

If this channel's file resides on a local storage device then when this method returns it is guaranteed that all changes made to the file since this channel was created, or since this method was last invoked, will have been written to that device. This is useful for ensuring that critical information is not lost in the event of a system crash.

If the file does not reside on a local device then no such guarantee is made.

The metaData parameter can be used to limit the number of I/O operations that this method is required to perform. Passing false for this parameter indicates that only updates to the file's content need be written to storage; passing true indicates that updates to both the file's content and metadata must be written, which generally requires at least one more I/O operation. Whether this parameter actually has any effect is dependent upon the underlying operating system and is therefore unspecified.

Invoking this method may cause an I/O operation to occur even if the channel was only opened for reading. Some operating systems, for example, maintain a last-access time as part of a file's metadata, and this time is updated whenever the file is read. Whether or not this is actually done is system-dependent and is therefore unspecified.

This method is only guaranteed to force changes that were made to this channel's file via the methods defined in this class.

Parameters
metaData:boolean

If true then this method is required to force changes to both the file's content and metadata to be written to storage; otherwise, it need only force content changes to be written

Annotations
@Override
Exceptions
IOException:
If some other I/O error occurs
implForceback to summary
private void implForce(boolean metaData) throws IOException
implLockback to summary
pack-priv <A> Future<FileLock> implLock(final long position, final long size, final boolean shared, final A attachment, final CompletionHandler<FileLock, ? super A> handler)

Implements abstract sun.nio.ch.AsynchronousFileChannelImpl.implLock.

Annotations
@Override
implReadback to summary
pack-priv <A> Future<Integer> implRead(final ByteBuffer dst, final long position, final A attachment, final CompletionHandler<Integer, ? super A> handler)

Implements abstract sun.nio.ch.AsynchronousFileChannelImpl.implRead.

Annotations
@Override
implReleaseback to summary
protected void implRelease(FileLockImpl fli) throws IOException

Implements abstract sun.nio.ch.AsynchronousFileChannelImpl.implRelease.

Doc from sun.nio.ch.AsynchronousFileChannelImpl.implRelease.

Releases the given file lock.

Annotations
@Override
implWriteback to summary
pack-priv <A> Future<Integer> implWrite(final ByteBuffer src, final long position, final A attachment, final CompletionHandler<Integer, ? super A> handler)

Implements abstract sun.nio.ch.AsynchronousFileChannelImpl.implWrite.

Annotations
@Override
openback to summary
public static AsynchronousFileChannel open(FileDescriptor fdo, String path, boolean reading, boolean writing, ThreadPool pool)
sizeback to summary
public long size() throws IOException

Implements abstract java.nio.channels.AsynchronousFileChannel.size.

Doc from java.nio.channels.AsynchronousFileChannel.size.

Returns the current size of this channel's file.

Returns:long

The current size of this channel's file, measured in bytes

Annotations
@Override
Exceptions
IOException:
If some other I/O error occurs
truncateback to summary
public AsynchronousFileChannel truncate(long size) throws IOException

Implements abstract java.nio.channels.AsynchronousFileChannel.truncate.

Doc from java.nio.channels.AsynchronousFileChannel.truncate.

Truncates this channel's file to the given size.

If the given size is less than the file's current size then the file is truncated, discarding any bytes beyond the new end of the file. If the given size is greater than or equal to the file's current size then the file is not modified.

Parameters
size:long

The new size, a non-negative byte count

Returns:AsynchronousFileChannel

This file channel

Annotations
@Override
Exceptions
IOException:
If some other I/O error occurs
tryLockback to summary
public FileLock tryLock(long position, long size, boolean shared) throws IOException

Implements abstract java.nio.channels.AsynchronousFileChannel.tryLock.

Doc from java.nio.channels.AsynchronousFileChannel.tryLock.

Attempts to acquire a lock on the given region of this channel's file.

This method does not block. An invocation always returns immediately, either having acquired a lock on the requested region or having failed to do so. If it fails to acquire a lock because an overlapping lock is held by another program then it returns null. If it fails to acquire a lock for any other reason then an appropriate exception is thrown. If the position is non-negative and the size is zero, then a lock of size Long.MAX_VALUE - position is returned.

Parameters
position:long

The position at which the locked region is to start; must be non-negative

size:long

The size of the locked region; must be non-negative, and the sum position + size must be non-negative. A value of zero means to lock all bytes from the specified starting position to the end of the file, regardless of whether the file is subsequently extended or truncated

shared:boolean

true to request a shared lock, false to request an exclusive lock

Returns:FileLock

A lock object representing the newly-acquired lock, or null if the lock could not be acquired because another program holds an overlapping lock

Annotations
@Override
Exceptions
IOException:
If some other I/O error occurs
sun.nio.ch back to summary

private Class SimpleAsynchronousFileChannelImpl.DefaultExecutorHolder

extends Object
Class Inheritance
  • java.lang.Object
  • sun.nio.ch.SimpleAsynchronousFileChannelImpl.DefaultExecutorHolder

Field Summary

Modifier and TypeField and Description
pack-priv static final ExecutorService

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

defaultExecutorback to summary
pack-priv static final ExecutorService defaultExecutor

Constructor Detail

DefaultExecutorHolderback to summary
private DefaultExecutorHolder()