Skip to content

Commit 400404c

Browse files
committed
Explicit Sendable conformances for @frozen types
Task groups and `UnsafeCurrentTask` are non-`Sendable`. `UnownedSerialExecutor` is always `Sendable`. Fixes rdar://86496341.
1 parent a901892 commit 400404c

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

stdlib/public/Concurrency/Executor.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public protocol SerialExecutor: Executor {
4646
/// actor.
4747
@available(SwiftStdlib 5.1, *)
4848
@frozen
49-
public struct UnownedSerialExecutor {
49+
public struct UnownedSerialExecutor: Sendable {
5050
#if compiler(>=5.5) && $BuiltinExecutor
5151
@usableFromInline
5252
internal var executor: Builtin.Executor

stdlib/public/Concurrency/Task.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,10 @@ public struct UnsafeCurrentTask {
717717
}
718718
}
719719

720+
@available(SwiftStdlib 5.1, *)
721+
@available(*, unavailable)
722+
extension UnsafeCurrentTask: Sendable { }
723+
720724
@available(SwiftStdlib 5.1, *)
721725
extension UnsafeCurrentTask: Hashable {
722726
public func hash(into hasher: inout Hasher) {

stdlib/public/Concurrency/TaskGroup.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,10 @@ public struct TaskGroup<ChildTaskResult: Sendable> {
383383
}
384384
}
385385

386+
@available(SwiftStdlib 5.1, *)
387+
@available(*, unavailable)
388+
extension TaskGroup: Sendable { }
389+
386390
// Implementation note:
387391
// We are unable to just™ abstract over Failure == Error / Never because of the
388392
// complicated relationship between `group.spawn` which dictates if `group.next`
@@ -639,6 +643,10 @@ public struct ThrowingTaskGroup<ChildTaskResult: Sendable, Failure: Error> {
639643
}
640644
}
641645

646+
@available(SwiftStdlib 5.1, *)
647+
@available(*, unavailable)
648+
extension ThrowingTaskGroup: Sendable { }
649+
642650
/// ==== TaskGroup: AsyncSequence ----------------------------------------------
643651

644652
@available(SwiftStdlib 5.1, *)

0 commit comments

Comments
 (0)