mirror of
https://github.com/swift-server/async-http-client.git
synced 2026-06-02 07:37:34 +00:00
30 lines
1.1 KiB
Swift
30 lines
1.1 KiB
Swift
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This source file is part of the AsyncHTTPClient open source project
|
|
//
|
|
// Copyright (c) 2022 Apple Inc. and the AsyncHTTPClient project authors
|
|
// Licensed under Apache License v2.0
|
|
//
|
|
// See LICENSE.txt for license information
|
|
// See CONTRIBUTORS.txt for the list of AsyncHTTPClient project authors
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// ``UnsafeMutableTransferBox`` can be used to make non-`Sendable` values `Sendable` and mutable.
|
|
/// It can be used to capture local mutable values in a `@Sendable` closure and mutate them from within the closure.
|
|
/// As the name implies, the usage of this is unsafe because it disables the sendable checking of the compiler and does not add any synchronisation.
|
|
@usableFromInline
|
|
final class UnsafeMutableTransferBox<Wrapped> {
|
|
@usableFromInline
|
|
var wrappedValue: Wrapped
|
|
|
|
@inlinable
|
|
init(_ wrappedValue: Wrapped) {
|
|
self.wrappedValue = wrappedValue
|
|
}
|
|
}
|
|
|
|
extension UnsafeMutableTransferBox: @unchecked Sendable {}
|