apple / swift-nio-transport-services

Extensions for SwiftNIO to support Apple platforms as first-class citizens.
https://swiftpackageindex.com/apple/swift-nio-transport-services/main/documentation/niotransportservices
Apache License 2.0
282 stars 71 forks source link

NIOSingletonsTransportServices: Use NIOTS in easy mode #180

Closed weissi closed 1 year ago

weissi commented 1 year ago

Motivation:

(companion PR to https://github.com/apple/swift-nio/pull/2471)

SwiftNIO allows and encourages to precisely manage all operating system resources like file descriptors & threads. That is a very important property of the system but in many places -- especially single Swift Concurrency arrived -- many simpler SwiftNIO programs only require a single, globally shared EventLoopGroup. Often even with just one thread.

Long story short: Many, probably most users would happily trade precise control over the threads for not having to pass around EventLoopGroups. Today, many of those users resort to creating (and often leaking) threads because it's simpler. Adding singletons type which lazily provide a singleton EventLoopGroup and an NIOThreadPool is IMHO a much better answer.

Modifications:

Result:

weissi commented 1 year ago

This cannot be merged until https://github.com/apple/swift-nio/pull/2471 has been released in NIO 2.57.0

weissi commented 1 year ago

With the NIO 2.58.0 release this should now go green

weissi commented 1 year ago

@Lukasa merging is currently blocked because it still has you down as a 'request changes', at your convenience PTAL