-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Unsafe pointers are no longer `Sendable`](swiftlang/swift#70396 (comment)) starting with Swift 5.10, while a warning in earlier versions. This PR introduces `SendableOpaquePointer` to wrap `OpaquePointer` and marks it as `@unchecked Sendable`. Resolves #159
- Loading branch information
Showing
3 changed files
with
50 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the swift-kafka-client open source project | ||
// | ||
// Copyright (c) 2024 Apple Inc. and the swift-kafka-client project authors | ||
// Licensed under Apache License v2.0 | ||
// | ||
// See LICENSE.txt for license information | ||
// See CONTRIBUTORS.txt for the list of swift-kafka-client project authors | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
/// A wrapper for the `OpaquePointer` used to represent different handles from `librdkafka`. | ||
/// | ||
/// This wrapper silences `Sendable` warnings for the pointer introduced in Swift 5.10, and should | ||
/// only be used for handles from `librdkafka` that are known to be thread-safe. | ||
internal struct SendableOpaquePointer: @unchecked Sendable { | ||
let pointer: OpaquePointer | ||
|
||
init(_ pointer: OpaquePointer) { | ||
self.pointer = pointer | ||
} | ||
} |