@@ -131,20 +131,20 @@ public final class TaskLocal<Value: Sendable>: Sendable, CustomStringConvertible
131
131
}
132
132
}
133
133
134
- /// Binds the task-local to the specific value for the duration of the body .
134
+ /// Binds the task-local to the specific value for the duration of the operation .
135
135
///
136
- /// The value is available throughout the execution of the body closure,
136
+ /// The value is available throughout the execution of the operation closure,
137
137
/// including any `get` operations performed by child-tasks created during the
138
- /// execution of the body closure.
138
+ /// execution of the operation closure.
139
139
///
140
140
/// If the same task-local is bound multiple times, be it in the same task, or
141
141
/// in specific child tasks, the more specific (i.e. "deeper") binding is
142
142
/// returned when the value is read.
143
143
///
144
144
/// If the value is a reference type, it will be retained for the duration of
145
- /// the body closure.
145
+ /// the operation closure.
146
146
@discardableResult
147
- public func withValue< R> ( _ valueDuringBody : Value , do body : ( ) async throws -> R ,
147
+ public func withValue< R> ( _ valueDuringOperation : Value , operation : ( ) async throws -> R ,
148
148
file: String = #file, line: UInt = #line) async rethrows -> R {
149
149
// check if we're not trying to bind a value from an illegal context; this may crash
150
150
_checkIllegalTaskLocalBindingWithinWithTaskGroup ( file: file, line: line)
@@ -155,10 +155,10 @@ public final class TaskLocal<Value: Sendable>: Sendable, CustomStringConvertible
155
155
task!. _task // !-safe, guaranteed to have task available inside async function
156
156
}
157
157
158
- _taskLocalValuePush ( _task, key: key, value: valueDuringBody )
158
+ _taskLocalValuePush ( _task, key: key, value: valueDuringOperation )
159
159
defer { _taskLocalValuePop ( _task) }
160
160
161
- return try await body ( )
161
+ return try await operation ( )
162
162
}
163
163
164
164
public var projectedValue : TaskLocal < Value > {
@@ -201,24 +201,24 @@ public final class TaskLocal<Value: Sendable>: Sendable, CustomStringConvertible
201
201
@available ( macOS 9999 , iOS 9999 , watchOS 9999 , tvOS 9999 , * )
202
202
extension UnsafeCurrentTask {
203
203
204
- /// Allows for executing a synchronous `body ` while binding a task-local value
204
+ /// Allows for executing a synchronous `operation ` while binding a task-local value
205
205
/// in the current task.
206
206
///
207
207
/// This function MUST NOT be invoked by any other task than the current task
208
208
/// represented by this object.
209
209
@discardableResult
210
210
public func withTaskLocal< Value: Sendable , R> (
211
211
_ taskLocal: TaskLocal < Value > ,
212
- boundTo valueDuringBody : Value ,
213
- do body : ( ) throws -> R ,
212
+ boundTo valueDuringOperation : Value ,
213
+ operation : ( ) throws -> R ,
214
214
file: String = #file, line: UInt = #line) rethrows -> R {
215
215
// check if we're not trying to bind a value from an illegal context; this may crash
216
216
_checkIllegalTaskLocalBindingWithinWithTaskGroup ( file: file, line: line)
217
217
218
- _taskLocalValuePush ( self . _task, key: taskLocal. key, value: valueDuringBody )
218
+ _taskLocalValuePush ( self . _task, key: taskLocal. key, value: valueDuringOperation )
219
219
defer { _taskLocalValuePop ( _task) }
220
220
221
- return try body ( )
221
+ return try operation ( )
222
222
}
223
223
}
224
224
0 commit comments