Top Description Fields Constructors Methods
org.newsclub.net.unix

pack-priv Class AFCore

extends CleanableState
Class Inheritance
Known Direct Subclasses
org.newsclub.net.unix.AFSocketCore
Imports
java.io.FileDescriptor, .IOException, java.net.SocketAddress, .SocketException, .SocketTimeoutException, java.nio.ByteBuffer, java.nio.channels.AsynchronousCloseException, .ClosedByInterruptException, .ClosedChannelException, .SelectionKey, java.util.Objects, java.util.concurrent.atomic.AtomicBoolean, .AtomicInteger, org.eclipse.jdt.annotation.NonNull, org.newsclub.net.unix.pool.MutableHolder, .ObjectPool, .ObjectPool.Lease, com.kohlschutter.annotations.compiletime.SuppressFBWarnings

The core functionality of file descriptor based I/O.
Author
Christian Kohlschütter

Field Summary

Modifier and TypeField and Description
pack-priv final AncillaryDataSupport
private volatile boolean
private boolean
private final AtomicBoolean
private final boolean
pack-priv final FileDescriptor
private static final String
private static final ObjectPool<MutableHolder<ByteBuffer>>
private static final int
private static final int
private final AtomicInteger

Constructor Summary

AccessConstructor and Description
pack-priv
AFCore(Object observed, FileDescriptor fd, AncillaryDataSupport ancillaryDataSupport, boolean datagramMode)

pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv void
configureVirtualBlocking(boolean
true if increment, false if decrement.
enabled
)

Increments/decrements the "virtual blocking" counter (calls must be in pairs/balanced using try-finally blocks).

pack-priv void
protected final void
doClean()

Implements abstract org.newsclub.net.unix.CleanableState.doClean.

Performs the actual cleanup.

pack-priv void
pack-priv ObjectPool.Lease<MutableHolder<@NonNull ByteBuffer>>

Returns:

A byte buffer satisfying the requested capacity.
getPrivateDirectByteBuffer
(int
The desired capacity.
capacity
)

Returns a per-thread reusable byte buffer for a given capacity.

pack-priv void
implConfigureBlocking(boolean block)

pack-priv boolean
pack-priv boolean
pack-priv boolean
pack-priv int
pack-priv int
read(ByteBuffer dst, AFSupplier<Integer> timeout, ByteBuffer socketAddressBuffer, int options)

pack-priv synchronized FileDescriptor
pack-priv FileDescriptor
pack-priv int
pack-priv int
write(ByteBuffer src, AFSupplier<Integer> timeout, SocketAddress target, int options)

Inherited from org.newsclub.net.unix.CleanableState:
closerunCleaner

Field Detail

ancillaryDataSupportback to summary
pack-priv final AncillaryDataSupport ancillaryDataSupport
blockingback to summary
private volatile boolean blocking
cleanFdback to summary
private boolean cleanFd
closedback to summary
private final AtomicBoolean closed
datagramModeback to summary
private final boolean datagramMode
fdback to summary
pack-priv final FileDescriptor fd
PROP_TL_BUFFER_MAX_CAPACITYback to summary
private static final String PROP_TL_BUFFER_MAX_CAPACITY
TL_BUFFERback to summary
private static final ObjectPool<MutableHolder<ByteBuffer>> TL_BUFFER
TL_BUFFER_MAX_CAPACITYback to summary
private static final int TL_BUFFER_MAX_CAPACITY
TL_BUFFER_MIN_CAPACITYback to summary
private static final int TL_BUFFER_MIN_CAPACITY
virtualBlockingLeasesback to summary
private final AtomicInteger virtualBlockingLeases

Constructor Detail

AFCoreback to summary
pack-priv AFCore(Object observed, FileDescriptor fd, AncillaryDataSupport ancillaryDataSupport, boolean datagramMode)
AFCoreback to summary
pack-priv AFCore(Object observed, FileDescriptor fd)

Method Detail

configureVirtualBlockingback to summary
pack-priv void configureVirtualBlocking(boolean enabled) throws SocketException, IOException

Increments/decrements the "virtual blocking" counter (calls must be in pairs/balanced using try-finally blocks).

Parameters
enabled:boolean

true if increment, false if decrement.

Exceptions
SocketException:
on error.
IOException:
on error, including count overflow/underflow.
disableCleanFdback to summary
pack-priv void disableCleanFd()
doCleanback to summary
protected final void doClean()

Implements abstract org.newsclub.net.unix.CleanableState.doClean.

Doc from org.newsclub.net.unix.CleanableState.doClean.

Performs the actual cleanup.

Annotations
@Override
doCloseback to summary
pack-priv void doClose() throws IOException
getPrivateDirectByteBufferback to summary
pack-priv ObjectPool.Lease<MutableHolder<@NonNull ByteBuffer>> getPrivateDirectByteBuffer(int capacity)

Returns a per-thread reusable byte buffer for a given capacity. If a thread-local buffer currently uses a smaller capacity, the buffer is replaced by a larger one. If the capacity exceeds a configurable maximum, a new direct buffer is allocated but not cached (i.e., the previously cached one is kept but not immediately returned to the caller).

Parameters
capacity:int

The desired capacity.

Returns:ObjectPool.Lease<MutableHolder<@NonNull ByteBuffer>>

A byte buffer satisfying the requested capacity.

Annotations
@SuppressWarnings:null
implConfigureBlockingback to summary
pack-priv void implConfigureBlocking(boolean block) throws IOException
isBlockingback to summary
pack-priv boolean isBlocking()
isClosedback to summary
pack-priv boolean isClosed()
isVirtualBlockingback to summary
pack-priv boolean isVirtualBlocking()
readback to summary
pack-priv int read(ByteBuffer dst, AFSupplier<Integer> timeout) throws IOException
readback to summary
pack-priv int read(ByteBuffer dst, AFSupplier<Integer> timeout, ByteBuffer socketAddressBuffer, int options) throws IOException
Annotations
@SuppressWarnings:PMD.NcssCount, PMD.CognitiveComplexity, PMD.CyclomaticComplexity, PMD.NPathComplexity
@SuppressFBWarnings:NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE
validFdback to summary
pack-priv synchronized FileDescriptor validFd()
validFdOrExceptionback to summary
pack-priv FileDescriptor validFdOrException() throws SocketException
writeback to summary
pack-priv int write(ByteBuffer src, AFSupplier<Integer> timeout) throws IOException
writeback to summary
pack-priv int write(ByteBuffer src, AFSupplier<Integer> timeout, SocketAddress target, int options) throws IOException
Annotations
@SuppressWarnings:PMD.NcssCount, PMD.CognitiveComplexity, PMD.CyclomaticComplexity, PMD.NPathComplexity
@SuppressFBWarnings:NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE