Take advantage of flatSubmit. (#62)

Motivation:

We can remove a couple of unnecessary flatMap { $0 } operations by way
of using flatSubmit, added in NIO 2.9.0.

Modifications:

- Replace flatMap { $0 } with flatSubmit().

Result:

Remove some code noise.
This commit is contained in:
Cory Benfield 2019-10-23 17:49:33 -07:00 committed by Johannes Weiss
parent e30bf63ea1
commit 6e8c20ed70
2 changed files with 4 additions and 4 deletions

View File

@ -169,7 +169,7 @@ public final class NIOTSConnectionBootstrap {
let initializer = self.channelInitializer ?? { _ in conn.eventLoop.makeSucceededFuture(()) }
let channelOptions = self.channelOptions
return conn.eventLoop.submit {
return conn.eventLoop.flatSubmit {
return channelOptions.applyAllChannelOptions(to: conn).flatMap {
initializer(conn)
}.flatMap {
@ -191,7 +191,7 @@ public final class NIOTSConnectionBootstrap {
conn.close(promise: nil)
throw $0
}
}.flatMap { $0 }
}
}
}

View File

@ -347,9 +347,9 @@ private class AcceptHandler: ChannelInboundHandler {
if childLoop === ctxEventLoop {
fireThroughPipeline(setupChildChannel())
} else {
fireThroughPipeline(childLoop.submit {
fireThroughPipeline(childLoop.flatSubmit {
return setupChildChannel()
}.flatMap { $0 }.hop(to: ctxEventLoop))
}.hop(to: ctxEventLoop))
}
}
}