withValue(_:operation:file:line:)
Binds the task-local to the specific value for the duration of the synchronous operation.
Declaration
@discardableResult final func withValue<R>(_ valueDuringOperation: Value, operation: () throws -> R, file: String = #fileID, line: UInt = #line) rethrows -> RDiscussion
The value is available throughout the execution of the operation closure, including any get operations performed by child-tasks created during the execution of the operation closure.
If the same task-local is bound multiple times, be it in the same task, or in specific child tasks, the “more specific” binding is returned when the value is read.
If the value is a reference type, it will be retained for the duration of the operation closure.