Couldn't agree more. Also with SwiftNIO Transport Services, SwiftNIO can actually run on top of Network.framework. In this case you'll use a different EventLoop type (NIOTSEventLoopGroup
instead of MultiThreadedEventLoopGroup
for NIO on BSD sockets) which executes on DispatchGroup
s. NIOTSEventLoopGroup
gives you all the same synchronisation guarantees as MultiThreadedEventLoopGroup
but the underlying thread may change (as DispatchGroup
s aren't bound to a thread). Long story short: Even considering only SwiftNIO you cannot universally assume that thread locals always work.
5 Likes