mirror of
https://github.com/apple/swift-nio-http2
synced 2026-11-23 04:34:24 +00:00
Motivation:
To address warnings revealed with
`.enableExperimentalFeature("StrictConcurrency=complete"),` in Swift 5.8
Modifications:
* Numerous protections of state in tests
* Make the multiplexer instances explicitly loop bound
* Update channel initializers to be marked as Sendable
* Mark error backing storage types as unchecked sendable
Result:
Better thread safety
33 lines
1.1 KiB
Swift
33 lines
1.1 KiB
Swift
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This source file is part of the SwiftNIO open source project
|
|
//
|
|
// Copyright (c) 2023 Apple Inc. and the SwiftNIO project authors
|
|
// Licensed under Apache License v2.0
|
|
//
|
|
// See LICENSE.txt for license information
|
|
// See CONTRIBUTORS.txt for the list of SwiftNIO project authors
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// ``UnsafeTransfer`` can be used to make non-`Sendable` values `Sendable`.
|
|
/// As the name implies, the usage of this is unsafe because it disables the sendable checking of the compiler.
|
|
/// It can be used similar to `@unsafe Sendable` but for values instead of types.
|
|
@usableFromInline
|
|
struct UnsafeTransfer<Wrapped> {
|
|
@usableFromInline
|
|
var wrappedValue: Wrapped
|
|
|
|
@inlinable
|
|
init(_ wrappedValue: Wrapped) {
|
|
self.wrappedValue = wrappedValue
|
|
}
|
|
}
|
|
|
|
extension UnsafeTransfer: @unchecked Sendable {}
|
|
|
|
extension UnsafeTransfer: Equatable where Wrapped: Equatable {}
|
|
extension UnsafeTransfer: Hashable where Wrapped: Hashable {}
|