in Sources/NIOPosix/BaseSocketChannel.swift [556:589]
func setOption0<Option: ChannelOption>(_ option: Option, value: Option.Value) throws {
self.eventLoop.assertInEventLoop()
guard isOpen else {
throw ChannelError.ioOnClosedChannel
}
switch option {
case let option as ChannelOptions.Types.SocketOption:
try self.setSocketOption0(level: option.optionLevel, name: option.optionName, value: value)
case _ as ChannelOptions.Types.AllocatorOption:
bufferAllocator = value as! ByteBufferAllocator
case _ as ChannelOptions.Types.RecvAllocatorOption:
recvAllocator = value as! RecvByteBufferAllocator
case _ as ChannelOptions.Types.AutoReadOption:
let auto = value as! Bool
let old = self.autoRead
self.autoRead = auto
// We only want to call read0() or pauseRead0() if we already registered to the EventLoop if not this will be automatically done
// once register0 is called. Beside this we also only need to do it when the value actually change.
if self.lifecycleManager.isPreRegistered && old != auto {
if auto {
read0()
} else {
pauseRead0()
}
}
case _ as ChannelOptions.Types.MaxMessagesPerReadOption:
maxMessagesPerRead = value as! UInt
default:
fatalError("option \(option) not supported")
}
}