diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3113cd32a..bed020268 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -67,6 +67,8 @@ jobs: with: runner_pool: nightly build_scheme: swift-nio-Package + xcode_16_2_build_arguments_override: "-Xswiftc -Xfrontend -Xswiftc -require-explicit-sendable" + xcode_16_3_build_arguments_override: "-Xswiftc -Xfrontend -Xswiftc -require-explicit-sendable" macos_xcode_test_enabled: false # Disabled because of an issue ios_xcode_test_enabled: true watchos_xcode_test_enabled: true diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 1cc0711f7..cd28e55fc 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -84,6 +84,8 @@ jobs: with: runner_pool: general build_scheme: swift-nio-Package + xcode_16_2_build_arguments_override: "-Xswiftc -Xfrontend -Xswiftc -require-explicit-sendable" + xcode_16_3_build_arguments_override: "-Xswiftc -Xfrontend -Xswiftc -require-explicit-sendable" static-sdk: name: Static SDK diff --git a/Sources/NIOConcurrencyHelpers/NIOLock.swift b/Sources/NIOConcurrencyHelpers/NIOLock.swift index 0fdc73aff..e05c15bb6 100644 --- a/Sources/NIOConcurrencyHelpers/NIOLock.swift +++ b/Sources/NIOConcurrencyHelpers/NIOLock.swift @@ -41,7 +41,7 @@ typealias LockPrimitive = pthread_mutex_t #endif @usableFromInline -enum LockOperations {} +enum LockOperations: Sendable {} extension LockOperations { @inlinable @@ -185,6 +185,13 @@ final class LockStorage: ManagedBuffer { } } +// This compiler guard is here becaue `ManagedBuffer` is already declaring +// Sendable unavailability after 6.1, which `LockStorage` inherits. +#if compiler(<6.2) +@available(*, unavailable) +extension LockStorage: Sendable {} +#endif + /// A threading lock based on `libpthread` instead of `libdispatch`. /// /// - Note: ``NIOLock`` has reference semantics. diff --git a/Sources/NIOConcurrencyHelpers/NIOLockedValueBox.swift b/Sources/NIOConcurrencyHelpers/NIOLockedValueBox.swift index 407588a75..55260fb75 100644 --- a/Sources/NIOConcurrencyHelpers/NIOLockedValueBox.swift +++ b/Sources/NIOConcurrencyHelpers/NIOLockedValueBox.swift @@ -80,3 +80,5 @@ public struct NIOLockedValueBox { } extension NIOLockedValueBox: @unchecked Sendable where Value: Sendable {} + +extension NIOLockedValueBox.Unsafe: @unchecked Sendable where Value: Sendable {} diff --git a/Sources/NIOCore/AsyncChannel/AsyncChannelHandler.swift b/Sources/NIOCore/AsyncChannel/AsyncChannelHandler.swift index 149c0ff5e..993982124 100644 --- a/Sources/NIOCore/AsyncChannel/AsyncChannelHandler.swift +++ b/Sources/NIOCore/AsyncChannel/AsyncChannelHandler.swift @@ -22,7 +22,7 @@ import DequeModule @usableFromInline internal final class NIOAsyncChannelHandler { @usableFromInline - enum _ProducingState { + enum _ProducingState: Sendable { // Not .stopProducing case keepProducing @@ -493,3 +493,6 @@ extension NIOAsyncChannelHandler { @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) @available(*, unavailable) extension NIOAsyncChannelHandler: Sendable {} + +@available(*, unavailable) +extension NIOAsyncChannelHandler.Transformation: Sendable {} diff --git a/Sources/NIOCore/AsyncChannel/AsyncChannelInboundStream.swift b/Sources/NIOCore/AsyncChannel/AsyncChannelInboundStream.swift index 7bda21cfd..31d89e7a2 100644 --- a/Sources/NIOCore/AsyncChannel/AsyncChannelInboundStream.swift +++ b/Sources/NIOCore/AsyncChannel/AsyncChannelInboundStream.swift @@ -26,7 +26,7 @@ public struct NIOAsyncChannelInboundStream: Sendable { > /// A source used for driving a ``NIOAsyncChannelInboundStream`` during tests. - public struct TestSource { + public struct TestSource: Sendable { @usableFromInline internal let continuation: AsyncThrowingStream.Continuation @@ -160,3 +160,6 @@ extension NIOAsyncChannelInboundStream: AsyncSequence { @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) @available(*, unavailable) extension NIOAsyncChannelInboundStream.AsyncIterator: Sendable {} + +@available(*, unavailable) +extension NIOAsyncChannelInboundStream.AsyncIterator._Backing: Sendable {} diff --git a/Sources/NIOCore/AsyncChannel/AsyncChannelOutboundWriter.swift b/Sources/NIOCore/AsyncChannel/AsyncChannelOutboundWriter.swift index dfdeeb0fd..1ffd665ee 100644 --- a/Sources/NIOCore/AsyncChannel/AsyncChannelOutboundWriter.swift +++ b/Sources/NIOCore/AsyncChannel/AsyncChannelOutboundWriter.swift @@ -166,3 +166,6 @@ public struct NIOAsyncChannelOutboundWriter: Sendable { @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) extension NIOAsyncChannelOutboundWriter.TestSink: Sendable {} + +@available(*, unavailable) +extension NIOAsyncChannelOutboundWriter.TestSink.AsyncIterator: Sendable {} diff --git a/Sources/NIOCore/AsyncSequences/NIOAsyncSequenceProducerStrategies.swift b/Sources/NIOCore/AsyncSequences/NIOAsyncSequenceProducerStrategies.swift index abed4fd87..961cf57f9 100644 --- a/Sources/NIOCore/AsyncSequences/NIOAsyncSequenceProducerStrategies.swift +++ b/Sources/NIOCore/AsyncSequences/NIOAsyncSequenceProducerStrategies.swift @@ -12,7 +12,7 @@ // //===----------------------------------------------------------------------===// -public enum NIOAsyncSequenceProducerBackPressureStrategies { +public enum NIOAsyncSequenceProducerBackPressureStrategies: Sendable { /// A high-low watermarked back-pressure strategy for a ``NIOAsyncSequenceProducer``. /// /// This strategy does the following: diff --git a/Sources/NIOCore/AsyncSequences/NIOAsyncWriter.swift b/Sources/NIOCore/AsyncSequences/NIOAsyncWriter.swift index f232d518f..185a27e63 100644 --- a/Sources/NIOCore/AsyncSequences/NIOAsyncWriter.swift +++ b/Sources/NIOCore/AsyncSequences/NIOAsyncWriter.swift @@ -140,7 +140,7 @@ public struct NIOAsyncWriter< /// This struct contains two properties: /// 1. The ``sink`` which should be retained by the consumer and is used to set the writability. /// 2. The ``writer`` which is the actual ``NIOAsyncWriter`` and should be passed to the producer. - public struct NewWriter { + public struct NewWriter: Sendable { /// The ``sink`` which **MUST** be retained by the consumer and is used to set the writability. public let sink: Sink /// The ``writer`` which is the actual ``NIOAsyncWriter`` and should be passed to the producer. @@ -339,7 +339,7 @@ extension NIOAsyncWriter { /// The underlying sink of the ``NIOAsyncWriter``. This type allows to set the writability of the ``NIOAsyncWriter``. /// /// - Important: Once all copies to the ``NIOAsyncWriter/Sink`` are destroyed the ``NIOAsyncWriter`` will get finished. - public struct Sink { + public struct Sink: Sendable { /// This class is needed to hook the deinit to observe once all references to the ``NIOAsyncWriter/Sink`` are dropped. @usableFromInline internal final class InternalClass: Sendable { @@ -746,7 +746,7 @@ extension NIOAsyncWriter { } /// The internal result of a yield. @usableFromInline - internal enum YieldResult { + internal enum YieldResult: Sendable { /// Indicates that the elements got yielded to the sink. case yielded /// Indicates that the yield should be retried. @@ -858,7 +858,7 @@ extension NIOAsyncWriter { /// Actions returned by `setWritability()`. @usableFromInline - enum SetWritabilityAction { + enum SetWritabilityAction: Sendable { /// Indicates that all writer continuations should be resumed. case resumeContinuations(_TinyArray) } @@ -983,7 +983,7 @@ extension NIOAsyncWriter { /// Actions returned by `yield()`. @usableFromInline - enum YieldAction { + enum YieldAction: Sendable { /// Indicates that ``NIOAsyncWriterSinkDelegate/didYield(contentsOf:)`` should be called. case callDidYield(Delegate) /// Indicates that the calling `Task` should get suspended. @@ -1214,7 +1214,7 @@ extension NIOAsyncWriter { /// Actions returned by `cancel()`. @usableFromInline - enum CancelAction { + enum CancelAction: Sendable { /// Indicates that the continuation should be resumed with a `CancellationError`. case resumeContinuationWithCancellationError(CheckedContinuation) /// Indicates that nothing should be done. @@ -1352,7 +1352,7 @@ extension NIOAsyncWriter { /// Actions returned by `writerFinish()`. @usableFromInline - enum WriterFinishAction { + enum WriterFinishAction: Sendable { /// Indicates that ``NIOAsyncWriterSinkDelegate/didTerminate(completion:)`` should be called. case callDidTerminate(Delegate) /// Indicates that all continuations should be resumed. @@ -1424,7 +1424,7 @@ extension NIOAsyncWriter { /// Actions returned by `sinkFinish()`. @usableFromInline - enum SinkFinishAction { + enum SinkFinishAction: Sendable { /// Indicates that all continuations should be resumed with the given error. case resumeContinuationsWithError(_TinyArray, Error) /// Indicates that nothing should be done. @@ -1469,7 +1469,7 @@ extension NIOAsyncWriter { /// Actions returned by `sinkFinish()`. @usableFromInline - enum UnbufferQueuedEventsAction { + enum UnbufferQueuedEventsAction: Sendable { case resumeContinuations(_TinyArray) case callDidTerminate(Delegate, Error?) } diff --git a/Sources/NIOCore/AsyncSequences/NIOThrowingAsyncSequenceProducer.swift b/Sources/NIOCore/AsyncSequences/NIOThrowingAsyncSequenceProducer.swift index 00c347b1d..e74cb93df 100644 --- a/Sources/NIOCore/AsyncSequences/NIOThrowingAsyncSequenceProducer.swift +++ b/Sources/NIOCore/AsyncSequences/NIOThrowingAsyncSequenceProducer.swift @@ -42,7 +42,7 @@ public struct NIOThrowingAsyncSequenceProducer< /// to yield new elements to the sequence. /// 2. The ``sequence`` which is the actual `AsyncSequence` and /// should be passed to the consumer. - public struct NewSequence { + public struct NewSequence: Sendable { /// The source of the ``NIOThrowingAsyncSequenceProducer`` used to yield and finish. public let source: Source /// The actual sequence which should be passed to the consumer. @@ -318,7 +318,7 @@ extension NIOThrowingAsyncSequenceProducer { } /// The result of a call to ``NIOThrowingAsyncSequenceProducer/Source/yield(_:)``. - public enum YieldResult: Hashable { + public enum YieldResult: Hashable, Sendable { /// Indicates that the caller should produce more elements. case produceMore /// Indicates that the caller should stop producing elements. @@ -782,7 +782,7 @@ extension NIOThrowingAsyncSequenceProducer { /// Actions returned by `sequenceDeinitialized()`. @usableFromInline - enum SequenceDeinitializedAction { + enum SequenceDeinitializedAction: Sendable { /// Indicates that ``NIOAsyncSequenceProducerDelegate/didTerminate()`` should be called. case callDidTerminate /// Indicates that nothing should be done. @@ -872,7 +872,7 @@ extension NIOThrowingAsyncSequenceProducer { /// Actions returned by `iteratorDeinitialized()`. @usableFromInline - enum IteratorDeinitializedAction { + enum IteratorDeinitializedAction: Sendable { /// Indicates that ``NIOAsyncSequenceProducerDelegate/didTerminate()`` should be called. case callDidTerminate /// Indicates that nothing should be done. @@ -911,7 +911,7 @@ extension NIOThrowingAsyncSequenceProducer { /// Actions returned by `yield()`. @usableFromInline - enum YieldAction { + enum YieldAction: Sendable { /// Indicates that ``NIOThrowingAsyncSequenceProducer/Source/YieldResult/produceMore`` should be returned. case returnProduceMore /// Indicates that ``NIOThrowingAsyncSequenceProducer/Source/YieldResult/stopProducing`` should be returned. @@ -1040,7 +1040,7 @@ extension NIOThrowingAsyncSequenceProducer { /// Actions returned by `finish()`. @usableFromInline - enum FinishAction { + enum FinishAction: Sendable { /// Indicates that the continuation should be resumed with `nil` and /// that ``NIOAsyncSequenceProducerDelegate/didTerminate()`` should be called. case resumeContinuationWithFailureAndCallDidTerminate(CheckedContinuation, Failure?) @@ -1092,7 +1092,7 @@ extension NIOThrowingAsyncSequenceProducer { /// Actions returned by `cancelled()`. @usableFromInline - enum CancelledAction { + enum CancelledAction: Sendable { /// Indicates that ``NIOAsyncSequenceProducerDelegate/didTerminate()`` should be called. case callDidTerminate /// Indicates that the continuation should be resumed with a `CancellationError` and @@ -1154,7 +1154,7 @@ extension NIOThrowingAsyncSequenceProducer { /// Actions returned by `next()`. @usableFromInline - enum NextAction { + enum NextAction: Sendable { /// Indicates that the element should be returned to the caller. case returnElement(Element) /// Indicates that the element should be returned to the caller and @@ -1268,7 +1268,7 @@ extension NIOThrowingAsyncSequenceProducer { /// Actions returned by `next(for:)`. @usableFromInline - enum NextForContinuationAction { + enum NextForContinuationAction: Sendable { /// Indicates that ``NIOAsyncSequenceProducerDelegate/produceMore()`` should be called. case callProduceMore /// Indicates that nothing should be done. diff --git a/Sources/NIOCore/ByteBuffer-core.swift b/Sources/NIOCore/ByteBuffer-core.swift index 07c568a25..add0340b7 100644 --- a/Sources/NIOCore/ByteBuffer-core.swift +++ b/Sources/NIOCore/ByteBuffer-core.swift @@ -1286,3 +1286,6 @@ extension ByteBuffer { return Range(uncheckedBounds: (lower: indexFromReaderIndex, upper: upperBound)) } } + +@available(*, unavailable) +extension ByteBuffer._Storage: Sendable {} diff --git a/Sources/NIOCore/ByteBuffer-quicBinaryEncodingStrategy.swift b/Sources/NIOCore/ByteBuffer-quicBinaryEncodingStrategy.swift index e5fa983ac..d4f276121 100644 --- a/Sources/NIOCore/ByteBuffer-quicBinaryEncodingStrategy.swift +++ b/Sources/NIOCore/ByteBuffer-quicBinaryEncodingStrategy.swift @@ -14,7 +14,7 @@ extension ByteBuffer { /// A ``NIOBinaryIntegerEncodingStrategy`` which encodes bytes as defined in RFC 9000 ยง 16 - public struct QUICBinaryEncodingStrategy: NIOBinaryIntegerEncodingStrategy { + public struct QUICBinaryEncodingStrategy: NIOBinaryIntegerEncodingStrategy, Sendable { /// All possible values for how many bytes a QUIC encoded integer can be public enum IntegerLength: Int, Sendable { case one = 1 diff --git a/Sources/NIOCore/Channel.swift b/Sources/NIOCore/Channel.swift index 4d3d664c1..d86362f6e 100644 --- a/Sources/NIOCore/Channel.swift +++ b/Sources/NIOCore/Channel.swift @@ -473,7 +473,7 @@ extension ChannelError: CustomStringConvertible { /// The removal of a `ChannelHandler` using `ChannelPipeline.removeHandler` has been attempted more than once. public struct NIOAttemptedToRemoveHandlerMultipleTimesError: Error {} -public enum DatagramChannelError { +public enum DatagramChannelError: Sendable { public struct WriteOnUnconnectedSocketWithoutAddress: Error { public init() {} } diff --git a/Sources/NIOCore/EventLoopFuture.swift b/Sources/NIOCore/EventLoopFuture.swift index 556551b4a..985c9cc8a 100644 --- a/Sources/NIOCore/EventLoopFuture.swift +++ b/Sources/NIOCore/EventLoopFuture.swift @@ -132,6 +132,9 @@ internal struct CallbackList { @available(*, unavailable) extension CallbackList: Sendable {} +@available(*, unavailable) +extension CallbackList.Wrapper: Sendable {} + /// Internal error for operations that return results that were not replaced @usableFromInline internal struct OperationPlaceholderError: Error { diff --git a/Sources/NIOCore/GlobalSingletons.swift b/Sources/NIOCore/GlobalSingletons.swift index 6b7d87264..3c151a1e6 100644 --- a/Sources/NIOCore/GlobalSingletons.swift +++ b/Sources/NIOCore/GlobalSingletons.swift @@ -38,7 +38,7 @@ import WinSDK /// `NIOSingletons.singletonsEnabledSuggestion = false`. All singleton-creating facilities should check /// this setting and if `false` restrain from creating any global singleton resources. Please note that disabling the /// global singletons will lead to a crash if _any_ code attempts to use any of the singletons. -public enum NIOSingletons { +public enum NIOSingletons: Sendable { } extension NIOSingletons { diff --git a/Sources/NIOCore/IO.swift b/Sources/NIOCore/IO.swift index b29e90536..cd359e947 100644 --- a/Sources/NIOCore/IO.swift +++ b/Sources/NIOCore/IO.swift @@ -45,7 +45,7 @@ import Darwin /// An `Error` for an IO operation. public struct IOError: Swift.Error { @available(*, deprecated, message: "NIO no longer uses FailureDescription.") - public enum FailureDescription { + public enum FailureDescription: Sendable { case function(StaticString) case reason(String) } diff --git a/Sources/NIOCore/IntegerBitPacking.swift b/Sources/NIOCore/IntegerBitPacking.swift index 40b6dd52d..6f3cdf71b 100644 --- a/Sources/NIOCore/IntegerBitPacking.swift +++ b/Sources/NIOCore/IntegerBitPacking.swift @@ -15,7 +15,7 @@ // FIXME: Duplicated in NIO. @usableFromInline -enum _IntegerBitPacking {} +enum _IntegerBitPacking: Sendable {} extension _IntegerBitPacking { @inlinable @@ -60,7 +60,7 @@ extension _IntegerBitPacking { } @usableFromInline -enum IntegerBitPacking {} +enum IntegerBitPacking: Sendable {} extension IntegerBitPacking { @inlinable diff --git a/Sources/NIOCore/SingleStepByteToMessageDecoder.swift b/Sources/NIOCore/SingleStepByteToMessageDecoder.swift index 82fcb039d..d69c5a7f0 100644 --- a/Sources/NIOCore/SingleStepByteToMessageDecoder.swift +++ b/Sources/NIOCore/SingleStepByteToMessageDecoder.swift @@ -187,7 +187,7 @@ extension NIOSingleStepByteToMessageDecoder { /// public final class NIOSingleStepByteToMessageProcessor { @usableFromInline - enum DecodeMode { + enum DecodeMode: Sendable { /// This is a usual decode, ie. not the last chunk case normal /// Last chunk diff --git a/Sources/NIOCore/UniversalBootstrapSupport.swift b/Sources/NIOCore/UniversalBootstrapSupport.swift index c3083781b..83f35057e 100644 --- a/Sources/NIOCore/UniversalBootstrapSupport.swift +++ b/Sources/NIOCore/UniversalBootstrapSupport.swift @@ -261,13 +261,16 @@ public struct NIOClientTCPBootstrap { } } +@available(*, unavailable) +extension NIOClientTCPBootstrap: Sendable {} + public protocol NIOClientTLSProvider { associatedtype Bootstrap func enableTLS(_ bootstrap: Bootstrap) -> Bootstrap } -public struct NIOInsecureNoTLS: NIOClientTLSProvider { +public struct NIOInsecureNoTLS: NIOClientTLSProvider, Sendable { public init() {} public func enableTLS(_ bootstrap: Bootstrap) -> Bootstrap { diff --git a/Sources/NIOCore/Utilities.swift b/Sources/NIOCore/Utilities.swift index 167b5c213..c547eb45b 100644 --- a/Sources/NIOCore/Utilities.swift +++ b/Sources/NIOCore/Utilities.swift @@ -69,7 +69,7 @@ final class Box { extension Box: Sendable where T: Sendable {} -public enum System { +public enum System: Sendable { /// A utility function that returns an estimate of the number of *logical* cores /// on the system available for use. /// diff --git a/Sources/NIOFileSystem/BufferedReader.swift b/Sources/NIOFileSystem/BufferedReader.swift index fabbd1238..d222c3a88 100644 --- a/Sources/NIOFileSystem/BufferedReader.swift +++ b/Sources/NIOFileSystem/BufferedReader.swift @@ -239,3 +239,6 @@ extension ReadableFileHandleProtocol { BufferedReader(wrapping: self, initialOffset: initialOffset, capacity: Int(capacity.bytes)) } } + +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) +extension BufferedReader: Sendable where Handle: Sendable {} diff --git a/Sources/NIOFileSystem/BufferedWriter.swift b/Sources/NIOFileSystem/BufferedWriter.swift index 23683ea08..95c05d0bf 100644 --- a/Sources/NIOFileSystem/BufferedWriter.swift +++ b/Sources/NIOFileSystem/BufferedWriter.swift @@ -243,3 +243,6 @@ extension WritableFileHandleProtocol { } } } + +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) +extension BufferedWriter: Sendable where Handle: Sendable {} diff --git a/Sources/NIOFileSystem/FileHandle.swift b/Sources/NIOFileSystem/FileHandle.swift index 3281a5d4f..6ed4e0ac1 100644 --- a/Sources/NIOFileSystem/FileHandle.swift +++ b/Sources/NIOFileSystem/FileHandle.swift @@ -246,7 +246,7 @@ public struct WriteFileHandle: WritableFileHandleProtocol, _HasFileHandle, Senda /// Implements ``ReadableAndWritableFileHandleProtocol`` by making system calls to interact with the /// local file system. @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) -public struct ReadWriteFileHandle: ReadableAndWritableFileHandleProtocol, _HasFileHandle { +public struct ReadWriteFileHandle: ReadableAndWritableFileHandleProtocol, _HasFileHandle, Sendable { public let fileHandle: FileHandle internal init(wrapping systemFileHandle: SystemFileHandle) { diff --git a/Sources/NIOFileSystem/FileSystemError+Syscall.swift b/Sources/NIOFileSystem/FileSystemError+Syscall.swift index 6b79112b8..280041e5c 100644 --- a/Sources/NIOFileSystem/FileSystemError+Syscall.swift +++ b/Sources/NIOFileSystem/FileSystemError+Syscall.swift @@ -435,7 +435,7 @@ extension FileSystemError { } @_spi(Testing) - public enum ReadSyscall: String { + public enum ReadSyscall: String, Sendable { case read case pread } @@ -487,7 +487,7 @@ extension FileSystemError { } @_spi(Testing) - public enum WriteSyscall: String { + public enum WriteSyscall: String, Sendable { case write case pwrite } diff --git a/Sources/NIOFileSystem/Internal/System Calls/Mocking.swift b/Sources/NIOFileSystem/Internal/System Calls/Mocking.swift index 4eef19637..50a48514b 100644 --- a/Sources/NIOFileSystem/Internal/System Calls/Mocking.swift +++ b/Sources/NIOFileSystem/Internal/System Calls/Mocking.swift @@ -77,8 +77,14 @@ public struct Trace { } } +@available(*, unavailable) +extension Trace: Sendable {} + +@available(*, unavailable) +extension Trace.Entry: Sendable {} + @_spi(Testing) -public enum ForceErrno: Equatable { +public enum ForceErrno: Equatable, Sendable { case none case always(errno: CInt) @@ -101,6 +107,9 @@ public final class MockingDriver { fileprivate var forceWindowsSyntaxForPaths = false } +@available(*, unavailable) +extension MockingDriver: Sendable {} + private let driverKey: _PlatformTLSKey = { makeTLSKey() }() internal var currentMockingDriver: MockingDriver? { diff --git a/Sources/NIOFileSystem/Internal/System Calls/Syscall.swift b/Sources/NIOFileSystem/Internal/System Calls/Syscall.swift index 0caf93df9..c3965c0f5 100644 --- a/Sources/NIOFileSystem/Internal/System Calls/Syscall.swift +++ b/Sources/NIOFileSystem/Internal/System Calls/Syscall.swift @@ -29,7 +29,7 @@ import CNIOLinux #endif @_spi(Testing) -public enum Syscall { +public enum Syscall: Sendable { @_spi(Testing) public static func stat(path: FilePath) -> Result { path.withPlatformString { platformPath in @@ -91,7 +91,7 @@ public enum Syscall { } @_spi(Testing) - public struct RenameOptions: OptionSet { + public struct RenameOptions: OptionSet, Sendable { public var rawValue: CUnsignedInt public init(rawValue: CUnsignedInt) { @@ -281,7 +281,7 @@ public enum Syscall { } @_spi(Testing) -public enum Libc { +public enum Libc: Sendable { static func readdir( _ dir: CInterop.DirPointer ) -> Result?, Errno> { diff --git a/Sources/NIOFileSystem/Internal/SystemFileHandle.swift b/Sources/NIOFileSystem/Internal/SystemFileHandle.swift index 53d35f88d..d02c5d154 100644 --- a/Sources/NIOFileSystem/Internal/SystemFileHandle.swift +++ b/Sources/NIOFileSystem/Internal/SystemFileHandle.swift @@ -371,7 +371,7 @@ extension SystemFileHandle: FileHandleProtocol { } @_spi(Testing) - public enum UpdatePermissionsOperation { case set, add, remove } + public enum UpdatePermissionsOperation: Sendable { case set, add, remove } } @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) diff --git a/Sources/NIOFileSystem/Internal/Utilities.swift b/Sources/NIOFileSystem/Internal/Utilities.swift index 9d6b94458..84440f106 100644 --- a/Sources/NIOFileSystem/Internal/Utilities.swift +++ b/Sources/NIOFileSystem/Internal/Utilities.swift @@ -24,6 +24,9 @@ internal final class Ref { } } +@available(*, unavailable) +extension Ref: Sendable {} + extension String { init(randomAlphaNumericOfLength length: Int) { precondition(length > 0) diff --git a/Sources/NIOFileSystem/OpenOptions.swift b/Sources/NIOFileSystem/OpenOptions.swift index 590724306..9730c734c 100644 --- a/Sources/NIOFileSystem/OpenOptions.swift +++ b/Sources/NIOFileSystem/OpenOptions.swift @@ -15,7 +15,7 @@ import SystemPackage /// Options for opening file handles. -public enum OpenOptions { +public enum OpenOptions: Sendable { /// Options for opening a file for reading. public struct Read: Hashable, Sendable { /// If the last path component is a symbolic link then this flag determines whether the diff --git a/Sources/NIOHTTP1/HTTPTypes.swift b/Sources/NIOHTTP1/HTTPTypes.swift index d82b044a6..8d569b61a 100644 --- a/Sources/NIOHTTP1/HTTPTypes.swift +++ b/Sources/NIOHTTP1/HTTPTypes.swift @@ -546,7 +546,7 @@ extension ByteBuffer { extension HTTPHeaders: RandomAccessCollection { public typealias Element = (name: String, value: String) - public struct Index: Comparable { + public struct Index: Comparable, Sendable { fileprivate let base: Array<(String, String)>.Index public static func < (lhs: Index, rhs: Index) -> Bool { lhs.base < rhs.base diff --git a/Sources/NIOPosix/IO.swift b/Sources/NIOPosix/IO.swift index b44c77cf9..beb871229 100644 --- a/Sources/NIOPosix/IO.swift +++ b/Sources/NIOPosix/IO.swift @@ -33,3 +33,5 @@ enum IOResult: Equatable { /// Signals that the IO operation was completed. case processed(T) } + +extension IOResult: Sendable where T: Sendable {} diff --git a/Sources/NIOPosix/IntegerBitPacking.swift b/Sources/NIOPosix/IntegerBitPacking.swift index fd8c135e8..142ef139a 100644 --- a/Sources/NIOPosix/IntegerBitPacking.swift +++ b/Sources/NIOPosix/IntegerBitPacking.swift @@ -13,7 +13,7 @@ //===----------------------------------------------------------------------===// @usableFromInline -enum _IntegerBitPacking {} +enum _IntegerBitPacking: Sendable {} extension _IntegerBitPacking { @inlinable @@ -58,7 +58,7 @@ extension _IntegerBitPacking { } @usableFromInline -enum IntegerBitPacking {} +enum IntegerBitPacking: Sendable {} extension IntegerBitPacking { @inlinable diff --git a/Sources/NIOPosix/VsockChannelEvents.swift b/Sources/NIOPosix/VsockChannelEvents.swift index 1a796f8ef..5b4c40374 100644 --- a/Sources/NIOPosix/VsockChannelEvents.swift +++ b/Sources/NIOPosix/VsockChannelEvents.swift @@ -13,7 +13,7 @@ //===----------------------------------------------------------------------===// import NIOCore -public enum VsockChannelEvents { +public enum VsockChannelEvents: Sendable { /// Fired as an outbound event when NIO would like to ask itself to bind the socket. /// /// This flow for connect is required because we cannot extend `enum SocketAddress` without diff --git a/Sources/NIOTestUtils/ByteToMessageDecoderVerifier.swift b/Sources/NIOTestUtils/ByteToMessageDecoderVerifier.swift index 5a30b0ebe..b0eb00510 100644 --- a/Sources/NIOTestUtils/ByteToMessageDecoderVerifier.swift +++ b/Sources/NIOTestUtils/ByteToMessageDecoderVerifier.swift @@ -14,7 +14,7 @@ import NIOCore import NIOEmbedded -public enum ByteToMessageDecoderVerifier { +public enum ByteToMessageDecoderVerifier: Sendable { /// - seealso: verifyDecoder(inputOutputPairs:decoderFactory:) /// /// Verify `ByteToMessageDecoder`s with `String` inputs @@ -240,6 +240,9 @@ extension ByteToMessageDecoderVerifier { } } +@available(*, unavailable) +extension ByteToMessageDecoderVerifier.VerificationError.ErrorCode: Sendable {} + /// `VerificationError` conforms to `Error` and therefore needs to conform to `Sendable` too. /// `VerificationError` has a stored property `errorCode` of type `ErrorCode` which can store `NIOAny` which is not and can not be `Sendable`. /// In addtion, `ErrorCode` can also store a user defined `OutputType` which is not required to be `Sendable` but we could require it to be `Sendable`.