apple / swift-nio-http2

HTTP/2 support for SwiftNIO
https://swiftpackageindex.com/apple/swift-nio-http2/main/documentation/niohttp2
Apache License 2.0
462 stars 82 forks source link

Add `Sendable` annotations to new async APIs #427

Closed FranzBusch closed 11 months ago

FranzBusch commented 11 months ago

Motivation

We just released our new async APIs but forgot to mark the new types as Sendable. This is causing warnings for users and we should properly mark them as Sendable since we expect users to use them from concurrent contexts.

Modification

Adding Sendable to the NIONegotiatedHTTPVersion was pretty straight forward; however, adding Sendable to AsyncStreamMultiplexer was a bit more complicated since it stored the InlineStreamMultiplexer which we cannot easily make Sendable. Hence, we are now holding the InlineStreamMultiplexer in a NIOLoopBound and are submitting the work to the correct EventLoop before we call the underlying multiplexer.

Result

No more Sendable warnings for our users.

FranzBusch commented 11 months ago

Let's close this in favour of @rnro PR then and work on the lense type a bit more.