Undo NWParameters as inout in configurator closure

NWParameters is a class, so we don't need it to be inout when passing it to the configurator closure
This commit is contained in:
Gus Cairo 2025-04-09 14:41:54 +01:00
parent 1f354a871f
commit fca19c5367
9 changed files with 31 additions and 31 deletions

View File

@ -47,7 +47,7 @@ public final class NIOTSDatagramBootstrap {
private var qos: DispatchQoS?
private var udpOptions: NWProtocolUDP.Options = .init()
private var tlsOptions: NWProtocolTLS.Options?
private var nwParametersConfigurator: (@Sendable (inout NWParameters) -> Void)?
private var nwParametersConfigurator: (@Sendable (NWParameters) -> Void)?
/// Create a `NIOTSDatagramConnectionBootstrap` on the `EventLoopGroup` `group`.
///
@ -136,7 +136,7 @@ public final class NIOTSDatagramBootstrap {
/// Customise the `NWParameters` to be used when creating the connection.
public func configureNWParameters(
_ configurator: @Sendable @escaping (inout NWParameters) -> Void
_ configurator: @Sendable @escaping (NWParameters) -> Void
) -> Self {
self.nwParametersConfigurator = configurator
return self

View File

@ -140,11 +140,11 @@ internal final class NIOTSDatagramChannel: StateManagedNWConnectionChannel {
internal var allowLocalEndpointReuse = false
internal var multipathServiceType: NWParameters.MultipathServiceType = .disabled
private let nwParametersConfigurator: (@Sendable (inout NWParameters) -> Void)?
private let nwParametersConfigurator: (@Sendable (NWParameters) -> Void)?
var parameters: NWParameters {
var parameters = NWParameters(dtls: self.tlsOptions, udp: self.udpOptions)
self.nwParametersConfigurator?(&parameters)
let parameters = NWParameters(dtls: self.tlsOptions, udp: self.udpOptions)
self.nwParametersConfigurator?(parameters)
return parameters
}
@ -187,7 +187,7 @@ internal final class NIOTSDatagramChannel: StateManagedNWConnectionChannel {
maximumReceiveLength: Int = 8192,
udpOptions: NWProtocolUDP.Options,
tlsOptions: NWProtocolTLS.Options?,
nwParametersConfigurator: (@Sendable (inout NWParameters) -> Void)?
nwParametersConfigurator: (@Sendable (NWParameters) -> Void)?
) {
self.tsEventLoop = eventLoop
self.closePromise = eventLoop.makePromise()
@ -213,7 +213,7 @@ internal final class NIOTSDatagramChannel: StateManagedNWConnectionChannel {
maximumReceiveLength: Int = 8192,
udpOptions: NWProtocolUDP.Options,
tlsOptions: NWProtocolTLS.Options?,
nwParametersConfigurator: (@Sendable (inout NWParameters) -> Void)?
nwParametersConfigurator: (@Sendable (NWParameters) -> Void)?
) {
self.init(
eventLoop: eventLoop,

View File

@ -66,7 +66,7 @@ public final class NIOTSDatagramListenerBootstrap {
private var udpOptions: NWProtocolUDP.Options = .init()
private var tlsOptions: NWProtocolTLS.Options?
private var bindTimeout: TimeAmount?
private var nwParametersConfigurator: (@Sendable (inout NWParameters) -> Void)?
private var nwParametersConfigurator: (@Sendable (NWParameters) -> Void)?
/// Create a ``NIOTSListenerBootstrap`` for the `EventLoopGroup` `group`.
///
@ -239,7 +239,7 @@ public final class NIOTSDatagramListenerBootstrap {
/// Customise the `NWParameters` to be used when creating the connection.
public func configureNWParameters(
_ configurator: @Sendable @escaping (inout NWParameters) -> Void
_ configurator: @Sendable @escaping (NWParameters) -> Void
) -> Self {
self.nwParametersConfigurator = configurator
return self

View File

@ -81,12 +81,12 @@ internal final class NIOTSDatagramListenerChannel: StateManagedListenerChannel<N
qos: DispatchQoS? = nil,
udpOptions: NWProtocolUDP.Options,
tlsOptions: NWProtocolTLS.Options?,
nwParametersConfigurator: (@Sendable (inout NWParameters) -> Void)?,
nwParametersConfigurator: (@Sendable (NWParameters) -> Void)?,
childLoopGroup: EventLoopGroup,
childChannelQoS: DispatchQoS?,
childUDPOptions: NWProtocolUDP.Options,
childTLSOptions: NWProtocolTLS.Options?,
childNWParametersConfigurator: (@Sendable (inout NWParameters) -> Void)?
childNWParametersConfigurator: (@Sendable (NWParameters) -> Void)?
) {
self.init(
eventLoop: eventLoop,
@ -108,12 +108,12 @@ internal final class NIOTSDatagramListenerChannel: StateManagedListenerChannel<N
qos: DispatchQoS? = nil,
udpOptions: NWProtocolUDP.Options,
tlsOptions: NWProtocolTLS.Options?,
nwParametersConfigurator: (@Sendable (inout NWParameters) -> Void)?,
nwParametersConfigurator: (@Sendable (NWParameters) -> Void)?,
childLoopGroup: EventLoopGroup,
childChannelQoS: DispatchQoS?,
childUDPOptions: NWProtocolUDP.Options,
childTLSOptions: NWProtocolTLS.Options?,
childNWParametersConfigurator: (@Sendable (inout NWParameters) -> Void)?
childNWParametersConfigurator: (@Sendable (NWParameters) -> Void)?
) {
self.init(
wrapping: listener,

View File

@ -62,7 +62,7 @@ public final class NIOTSConnectionBootstrap {
private var tcpOptions: NWProtocolTCP.Options = .init()
private var tlsOptions: NWProtocolTLS.Options?
private var protocolHandlers: (@Sendable () -> [ChannelHandler])? = nil
private var nwParametersConfigurator: (@Sendable (inout NWParameters) -> Void)?
private var nwParametersConfigurator: (@Sendable (NWParameters) -> Void)?
/// Create a `NIOTSConnectionBootstrap` on the `EventLoopGroup` `group`.
///
@ -168,7 +168,7 @@ public final class NIOTSConnectionBootstrap {
/// Customise the `NWParameters` to be used when creating the connection.
public func configureNWParameters(
_ configurator: @Sendable @escaping (inout NWParameters) -> Void
_ configurator: @Sendable @escaping (NWParameters) -> Void
) -> Self {
self.nwParametersConfigurator = configurator
return self

View File

@ -164,11 +164,11 @@ internal final class NIOTSConnectionChannel: StateManagedNWConnectionChannel {
/// An `EventLoopPromise` that will be succeeded or failed when a connection attempt succeeds or fails.
internal var connectPromise: EventLoopPromise<Void>?
private let nwParametersConfigurator: (@Sendable (inout NWParameters) -> Void)?
private let nwParametersConfigurator: (@Sendable (NWParameters) -> Void)?
internal var parameters: NWParameters {
var parameters = NWParameters(tls: self.tlsOptions, tcp: self.tcpOptions)
self.nwParametersConfigurator?(&parameters)
let parameters = NWParameters(tls: self.tlsOptions, tcp: self.tcpOptions)
self.nwParametersConfigurator?(parameters)
return parameters
}
@ -247,7 +247,7 @@ internal final class NIOTSConnectionChannel: StateManagedNWConnectionChannel {
maximumReceiveLength: Int = 8192,
tcpOptions: NWProtocolTCP.Options,
tlsOptions: NWProtocolTLS.Options?,
nwParametersConfigurator: (@Sendable (inout NWParameters) -> Void)?
nwParametersConfigurator: (@Sendable (NWParameters) -> Void)?
) {
self.tsEventLoop = eventLoop
self.closePromise = eventLoop.makePromise()
@ -273,7 +273,7 @@ internal final class NIOTSConnectionChannel: StateManagedNWConnectionChannel {
maximumReceiveLength: Int = 8192,
tcpOptions: NWProtocolTCP.Options,
tlsOptions: NWProtocolTLS.Options?,
nwParametersConfigurator: (@Sendable (inout NWParameters) -> Void)?
nwParametersConfigurator: (@Sendable (NWParameters) -> Void)?
) {
self.init(
eventLoop: eventLoop,

View File

@ -66,7 +66,7 @@ public final class NIOTSListenerBootstrap {
private var tcpOptions: NWProtocolTCP.Options = .init()
private var tlsOptions: NWProtocolTLS.Options?
private var bindTimeout: TimeAmount?
private var nwParametersConfigurator: (@Sendable (inout NWParameters) -> Void)?
private var nwParametersConfigurator: (@Sendable (NWParameters) -> Void)?
/// Create a ``NIOTSListenerBootstrap`` for the `EventLoopGroup` `group`.
///

View File

@ -81,12 +81,12 @@ internal final class NIOTSListenerChannel: StateManagedListenerChannel<NIOTSConn
qos: DispatchQoS? = nil,
tcpOptions: NWProtocolTCP.Options,
tlsOptions: NWProtocolTLS.Options?,
nwParametersConfigurator: (@Sendable (inout NWParameters) -> Void)?,
nwParametersConfigurator: (@Sendable (NWParameters) -> Void)?,
childLoopGroup: EventLoopGroup,
childChannelQoS: DispatchQoS?,
childTCPOptions: NWProtocolTCP.Options,
childTLSOptions: NWProtocolTLS.Options?,
childNWParametersConfigurator: (@Sendable (inout NWParameters) -> Void)?
childNWParametersConfigurator: (@Sendable (NWParameters) -> Void)?
) {
self.init(
eventLoop: eventLoop,
@ -108,12 +108,12 @@ internal final class NIOTSListenerChannel: StateManagedListenerChannel<NIOTSConn
qos: DispatchQoS? = nil,
tcpOptions: NWProtocolTCP.Options,
tlsOptions: NWProtocolTLS.Options?,
nwParametersConfigurator: (@Sendable (inout NWParameters) -> Void)?,
nwParametersConfigurator: (@Sendable (NWParameters) -> Void)?,
childLoopGroup: EventLoopGroup,
childChannelQoS: DispatchQoS?,
childTCPOptions: NWProtocolTCP.Options,
childTLSOptions: NWProtocolTLS.Options?,
childNWParametersConfigurator: (@Sendable (inout NWParameters) -> Void)?
childNWParametersConfigurator: (@Sendable (NWParameters) -> Void)?
) {
self.init(
wrapping: listener,

View File

@ -67,7 +67,7 @@ internal class StateManagedListenerChannel<ChildChannel: StateManagedChannel>: S
/// The TLS options for this listener.
internal let tlsOptions: NWProtocolTLS.Options?
internal var nwParametersConfigurator: (@Sendable (inout NWParameters) -> Void)?
internal var nwParametersConfigurator: (@Sendable (NWParameters) -> Void)?
/// The `DispatchQueue` that socket events for this connection will be dispatched onto.
internal let connectionQueue: DispatchQueue
@ -115,7 +115,7 @@ internal class StateManagedListenerChannel<ChildChannel: StateManagedChannel>: S
/// The TLS options to use for child channels.
internal let childTLSOptions: NWProtocolTLS.Options?
internal var childNWParametersConfigurator: (@Sendable (inout NWParameters) -> Void)?
internal var childNWParametersConfigurator: (@Sendable (NWParameters) -> Void)?
/// The cache of the local and remote socket addresses. Must be accessed using _addressCacheLock.
internal var addressCache = AddressCache(local: nil, remote: nil)
@ -134,12 +134,12 @@ internal class StateManagedListenerChannel<ChildChannel: StateManagedChannel>: S
qos: DispatchQoS? = nil,
protocolOptions: ProtocolOptions,
tlsOptions: NWProtocolTLS.Options?,
nwParametersConfigurator: (@Sendable (inout NWParameters) -> Void)?,
nwParametersConfigurator: (@Sendable (NWParameters) -> Void)?,
childLoopGroup: EventLoopGroup,
childChannelQoS: DispatchQoS?,
childProtocolOptions: ProtocolOptions,
childTLSOptions: NWProtocolTLS.Options?,
childNWParametersConfigurator: (@Sendable (inout NWParameters) -> Void)?
childNWParametersConfigurator: (@Sendable (NWParameters) -> Void)?
) {
self.tsEventLoop = eventLoop
self.closePromise = eventLoop.makePromise()
@ -161,12 +161,12 @@ internal class StateManagedListenerChannel<ChildChannel: StateManagedChannel>: S
qos: DispatchQoS? = nil,
protocolOptions: ProtocolOptions,
tlsOptions: NWProtocolTLS.Options?,
nwParametersConfigurator: (@Sendable (inout NWParameters) -> Void)?,
nwParametersConfigurator: (@Sendable (NWParameters) -> Void)?,
childLoopGroup: EventLoopGroup,
childChannelQoS: DispatchQoS?,
childProtocolOptions: ProtocolOptions,
childTLSOptions: NWProtocolTLS.Options?,
childNWParametersConfigurator: (@Sendable (inout NWParameters) -> Void)?
childNWParametersConfigurator: (@Sendable (NWParameters) -> Void)?
) {
self.init(
eventLoop: eventLoop,