read(fileRegion:allocator:eventLoop:)

Read a FileRegion in NonBlockingFileIO’s private thread pool which is separate from any EventLoop thread.

NonBlockingFileIO.swift:273
func read(fileRegion: FileRegion, allocator: ByteBufferAllocator, eventLoop: any EventLoop) -> EventLoopFuture<ByteBuffer>

Parameters

fileRegion

The file region to read.

allocator

A ByteBufferAllocator used to allocate space for the returned ByteBuffer.

eventLoop

The EventLoop to create the returned EventLoopFuture from.

Returns

An EventLoopFuture which delivers a ByteBuffer if the read was successful or a failure on error.

The returned ByteBuffer will not have less than fileRegion.readableBytes unless we hit end-of-file in which case the ByteBuffer will contain the bytes available to read.

This method will not use the file descriptor’s seek pointer which means there is no danger of reading from the same FileRegion in multiple threads.