Adopt `Sendable` in `ChannelPipeline.swift` and `ChannelInvoker.swift` (#2143)

This commit is contained in:
David Nadoba 2022-06-01 17:42:24 +02:00 committed by GitHub
parent 4574bdde82
commit 9c60117db0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 2 deletions

View File

@ -231,7 +231,7 @@ public protocol ChannelInboundInvoker {
public protocol ChannelInvoker: ChannelOutboundInvoker, ChannelInboundInvoker { }
/// Specify what kind of close operation is requested.
public enum CloseMode {
public enum CloseMode: NIOSendable {
/// Close the output (writing) side of the `Channel` without closing the actual file descriptor.
/// This is an optional mode which means it may not be supported by all `Channel` implementations.
case output

View File

@ -946,6 +946,10 @@ public final class ChannelPipeline: ChannelInvoker {
}
}
#if swift(>=5.7)
extension ChannelPipeline: @unchecked Sendable {}
#endif
extension ChannelPipeline {
/// Adds the provided channel handlers to the pipeline in the order given, taking account
/// of the behaviour of `ChannelHandler.add(first:)`.
@ -1270,6 +1274,11 @@ extension ChannelPipeline {
}
}
#if swift(>=5.7)
@available(*, unavailable)
extension ChannelPipeline.SynchronousOperations: Sendable {}
#endif
extension ChannelPipeline {
/// A `Position` within the `ChannelPipeline` used to insert handlers into the `ChannelPipeline`.
public enum Position {
@ -1287,6 +1296,11 @@ extension ChannelPipeline {
}
}
#if swift(>=5.7)
@available(*, unavailable)
extension ChannelPipeline.Position: Sendable {}
#endif
/// Special `ChannelHandler` that forwards all events to the `Channel.Unsafe` implementation.
/* private but tests */ final class HeadChannelHandler: _ChannelOutboundHandler {
@ -1839,11 +1853,16 @@ public final class ChannelHandlerContext: ChannelInvoker {
}
}
#if swift(>=5.7)
@available(*, unavailable)
extension ChannelHandlerContext: Sendable {}
#endif
extension ChannelHandlerContext {
/// A `RemovalToken` is handed to a `RemovableChannelHandler` when its `removeHandler` function is invoked. A
/// `RemovableChannelHandler` is then required to remove itself from the `ChannelPipeline`. The removal process
/// is finalized by handing the `RemovalToken` to the `ChannelHandlerContext.leavePipeline` function.
public struct RemovalToken {
public struct RemovalToken: NIOSendable {
internal let promise: EventLoopPromise<Void>?
}