Package io.netty.channel.uring
Class IoUringFileRegion
- java.lang.Object
-
- io.netty.channel.uring.IoUringFileRegion
-
- All Implemented Interfaces:
FileRegion,ReferenceCounted
final class IoUringFileRegion extends java.lang.Object implements FileRegion
-
-
Field Summary
Fields Modifier and Type Field Description (package private) DefaultFileRegionfileRegionprivate static InternalLoggerloggerprivate FileDescriptor[]pipeprivate intpipeLenprivate static shortSPLICE_TO_PIPEprivate static shortSPLICE_TO_SOCKETprivate inttransferred
-
Constructor Summary
Constructors Constructor Description IoUringFileRegion(DefaultFileRegion fileRegion)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidclosePipeIfNeeded()private static voidcloseSilently(FileDescriptor fd)longcount()Returns the number of bytes to transfer.(package private) inthandleResult(int result, short data)Handle splice result(package private) voidopen()longposition()Returns the offset in the file where the transfer began.intrefCnt()Returns the reference count of this object.booleanrelease()Decreases the reference count by1and deallocates this object if the reference count reaches at0.booleanrelease(int decrement)Decreases the reference count by the specifieddecrementand deallocates this object if the reference count reaches at0.FileRegionretain()Increases the reference count by1.FileRegionretain(int increment)Increases the reference count by the specifiedincrement.(package private) IoUringIoOpssplice(int fd)(package private) IoUringIoOpsspliceToPipe()private IoUringIoOpsspliceToSocket(int socket, int len)FileRegiontouch()Records the current access location of this object for debugging purposes.FileRegiontouch(java.lang.Object hint)Records the current access location of this object with an additional arbitrary information for debugging purposes.longtransfered()Returns the bytes which was transferred already.longtransferred()Returns the bytes which was transferred already.longtransferTo(java.nio.channels.WritableByteChannel target, long position)Transfers the content of this file region to the specified channel.
-
-
-
Field Detail
-
logger
private static final InternalLogger logger
-
SPLICE_TO_PIPE
private static final short SPLICE_TO_PIPE
- See Also:
- Constant Field Values
-
SPLICE_TO_SOCKET
private static final short SPLICE_TO_SOCKET
- See Also:
- Constant Field Values
-
fileRegion
final DefaultFileRegion fileRegion
-
pipe
private FileDescriptor[] pipe
-
transferred
private int transferred
-
pipeLen
private int pipeLen
-
-
Constructor Detail
-
IoUringFileRegion
IoUringFileRegion(DefaultFileRegion fileRegion)
-
-
Method Detail
-
open
void open() throws java.io.IOException
- Throws:
java.io.IOException
-
splice
IoUringIoOps splice(int fd)
-
spliceToPipe
IoUringIoOps spliceToPipe()
-
spliceToSocket
private IoUringIoOps spliceToSocket(int socket, int len)
-
handleResult
int handleResult(int result, short data)Handle splice result- Parameters:
result- the resultdata- the data that was submitted as part of the SPLICE.- Returns:
- the number of bytes that should be considered to be transferred.
-
position
public long position()
Description copied from interface:FileRegionReturns the offset in the file where the transfer began.- Specified by:
positionin interfaceFileRegion
-
transfered
public long transfered()
Description copied from interface:FileRegionReturns the bytes which was transferred already.- Specified by:
transferedin interfaceFileRegion
-
transferred
public long transferred()
Description copied from interface:FileRegionReturns the bytes which was transferred already.Note: some asynchronous transports (such as the
io_uringtransport when falling back to a chunked send for non-DefaultFileRegionimplementations) advance this counter when bytes have been queued for submission, which may be before they reach the peer. If the channel is closed or the write fails after queuing, the reported value may overstate the number of bytes actually delivered.- Specified by:
transferredin interfaceFileRegion
-
count
public long count()
Description copied from interface:FileRegionReturns the number of bytes to transfer.- Specified by:
countin interfaceFileRegion
-
transferTo
public long transferTo(java.nio.channels.WritableByteChannel target, long position)Description copied from interface:FileRegionTransfers the content of this file region to the specified channel.- Specified by:
transferToin interfaceFileRegion- Parameters:
target- the destination of the transferposition- the relative offset of the file where the transfer begins from. For example, 0 will make the transfer start fromFileRegion.position()th byte andFileRegion.count()- 1 will make the last byte of the region transferred.
-
retain
public FileRegion retain()
Description copied from interface:ReferenceCountedIncreases the reference count by1.- Specified by:
retainin interfaceFileRegion- Specified by:
retainin interfaceReferenceCounted
-
retain
public FileRegion retain(int increment)
Description copied from interface:ReferenceCountedIncreases the reference count by the specifiedincrement.- Specified by:
retainin interfaceFileRegion- Specified by:
retainin interfaceReferenceCounted
-
touch
public FileRegion touch()
Description copied from interface:ReferenceCountedRecords the current access location of this object for debugging purposes. If this object is determined to be leaked, the information recorded by this operation will be provided to you viaResourceLeakDetector. This method is a shortcut totouch(null).- Specified by:
touchin interfaceFileRegion- Specified by:
touchin interfaceReferenceCounted
-
touch
public FileRegion touch(java.lang.Object hint)
Description copied from interface:ReferenceCountedRecords the current access location of this object with an additional arbitrary information for debugging purposes. If this object is determined to be leaked, the information recorded by this operation will be provided to you viaResourceLeakDetector.- Specified by:
touchin interfaceFileRegion- Specified by:
touchin interfaceReferenceCounted
-
refCnt
public int refCnt()
Description copied from interface:ReferenceCountedReturns the reference count of this object. If0, it means this object has been deallocated.- Specified by:
refCntin interfaceReferenceCounted
-
release
public boolean release()
Description copied from interface:ReferenceCountedDecreases the reference count by1and deallocates this object if the reference count reaches at0.- Specified by:
releasein interfaceReferenceCounted- Returns:
trueif and only if the reference count became0and this object has been deallocated
-
release
public boolean release(int decrement)
Description copied from interface:ReferenceCountedDecreases the reference count by the specifieddecrementand deallocates this object if the reference count reaches at0.- Specified by:
releasein interfaceReferenceCounted- Returns:
trueif and only if the reference count became0and this object has been deallocated
-
closePipeIfNeeded
private void closePipeIfNeeded()
-
closeSilently
private static void closeSilently(FileDescriptor fd)
-
-