Skip to content

Commit 9b82170

Browse files
committed
Better fix, using inheriting executor
1 parent fb996b8 commit 9b82170

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

stdlib/public/BackDeployConcurrency/TaskLocal.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ public final class TaskLocal<Value: Sendable>: Sendable, CustomStringConvertible
134134
///
135135
/// If the value is a reference type, it will be retained for the duration of
136136
/// the operation closure.
137-
@Sendable
138137
@discardableResult
139-
public func withValue<R>(_ valueDuringOperation: Value, operation: @Sendable () async throws -> R,
138+
@_unsafeInheritExecutor
139+
public func withValue<R>(_ valueDuringOperation: Value, operation: () async throws -> R,
140140
file: String = #file, line: UInt = #line) async rethrows -> R {
141141
// check if we're not trying to bind a value from an illegal context; this may crash
142142
_checkIllegalTaskLocalBindingWithinWithTaskGroup(file: file, line: line)

stdlib/public/Concurrency/TaskLocal.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ public final class TaskLocal<Value: Sendable>: Sendable, CustomStringConvertible
135135
/// If the value is a reference type, it will be retained for the duration of
136136
/// the operation closure.
137137
@discardableResult
138-
public func withValue<R>(_ valueDuringOperation: Value, operation: @Sendable () async throws -> R,
138+
@_unsafeInheritExecutor
139+
public func withValue<R>(_ valueDuringOperation: Value, operation: () async throws -> R,
139140
file: String = #fileID, line: UInt = #line) async rethrows -> R {
140141
// check if we're not trying to bind a value from an illegal context; this may crash
141142
_checkIllegalTaskLocalBindingWithinWithTaskGroup(file: file, line: line)

0 commit comments

Comments
 (0)