Skip to content

Commit d25ac31

Browse files
committed
[TaskLocals] rename 'do body' to 'operation' parameter
1 parent 2b358d9 commit d25ac31

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

stdlib/public/Concurrency/TaskLocal.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -131,20 +131,20 @@ public final class TaskLocal<Value: Sendable>: Sendable, CustomStringConvertible
131131
}
132132
}
133133

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.
135135
///
136-
/// The value is available throughout the execution of the body closure,
136+
/// The value is available throughout the execution of the operation closure,
137137
/// including any `get` operations performed by child-tasks created during the
138-
/// execution of the body closure.
138+
/// execution of the operation closure.
139139
///
140140
/// If the same task-local is bound multiple times, be it in the same task, or
141141
/// in specific child tasks, the more specific (i.e. "deeper") binding is
142142
/// returned when the value is read.
143143
///
144144
/// If the value is a reference type, it will be retained for the duration of
145-
/// the body closure.
145+
/// the operation closure.
146146
@discardableResult
147-
public func withValue<R>(_ valueDuringBody: Value, do body: () async throws -> R,
147+
public func withValue<R>(_ valueDuringOperation: Value, operation: () async throws -> R,
148148
file: String = #file, line: UInt = #line) async rethrows -> R {
149149
// check if we're not trying to bind a value from an illegal context; this may crash
150150
_checkIllegalTaskLocalBindingWithinWithTaskGroup(file: file, line: line)
@@ -155,10 +155,10 @@ public final class TaskLocal<Value: Sendable>: Sendable, CustomStringConvertible
155155
task!._task // !-safe, guaranteed to have task available inside async function
156156
}
157157

158-
_taskLocalValuePush(_task, key: key, value: valueDuringBody)
158+
_taskLocalValuePush(_task, key: key, value: valueDuringOperation)
159159
defer { _taskLocalValuePop(_task) }
160160

161-
return try await body()
161+
return try await operation()
162162
}
163163

164164
public var projectedValue: TaskLocal<Value> {
@@ -201,24 +201,24 @@ public final class TaskLocal<Value: Sendable>: Sendable, CustomStringConvertible
201201
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
202202
extension UnsafeCurrentTask {
203203

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
205205
/// in the current task.
206206
///
207207
/// This function MUST NOT be invoked by any other task than the current task
208208
/// represented by this object.
209209
@discardableResult
210210
public func withTaskLocal<Value: Sendable, R>(
211211
_ taskLocal: TaskLocal<Value>,
212-
boundTo valueDuringBody: Value,
213-
do body: () throws -> R,
212+
boundTo valueDuringOperation: Value,
213+
operation: () throws -> R,
214214
file: String = #file, line: UInt = #line) rethrows -> R {
215215
// check if we're not trying to bind a value from an illegal context; this may crash
216216
_checkIllegalTaskLocalBindingWithinWithTaskGroup(file: file, line: line)
217217

218-
_taskLocalValuePush(self._task, key: taskLocal.key, value: valueDuringBody)
218+
_taskLocalValuePush(self._task, key: taskLocal.key, value: valueDuringOperation)
219219
defer { _taskLocalValuePop(_task) }
220220

221-
return try body()
221+
return try operation()
222222
}
223223
}
224224

0 commit comments

Comments
 (0)