read(fileHandle:byteCount:allocator:eventLoop:)

Read byteCount bytes from fileHandle in NonBlockingFileIO’s private thread pool which is separate from any EventLoop thread.

NonBlockingFileIO.swift:304
func read(fileHandle: NIOFileHandle, byteCount: Int, allocator: ByteBufferAllocator, eventLoop: EventLoop) -> EventLoopFuture<ByteBuffer>

Parameters

fileHandle

The NIOFileHandle to read.

byteCount

The number of bytes to read from fileHandle.

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 byteCount bytes unless we hit end-of-file in which case the ByteBuffer will contain the bytes available to read.