@@ -6,6 +6,42 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
66Swift 5.5
77---------
88
9+ * [ SE-0311] [ ] :
10+
11+ Task local values offer a can be defined using the new ` @TaskLocal ` property wrapper.
12+ Such values are carried implicitly by the task in which the binding was made,
13+ as well as any child-tasks, and unstructured task created from the tasks context.
14+
15+ ``` swift
16+ struct TraceID {
17+ @TaskLocal
18+ static var current: TraceID?
19+ }
20+
21+ func printTraceID () {
22+ if let traceID = TraceID.current {
23+ print (" \( traceID ) " )
24+ } else {
25+ print (" nil" )
26+ }
27+ }
28+
29+ func run () async {
30+ printTraceID () // prints: nil
31+ TraceID.$current.withValue (" 1234-5678" ) {
32+ printTraceID () // prints: 1234-5678
33+ inner () // prints: 1234-5678
34+ }
35+ printTraceID () // prints: nil
36+ }
37+
38+ func inner () {
39+ // if called from a context in which the task-local value
40+ // was bound, it will print it (or 'nil' otherwise)
41+ printTraceID ()
42+ }
43+ ```
44+
945* [ SE-0316] [ ] :
1046
1147 A type can be defined as a global actor. Global actors extend the notion
@@ -8562,6 +8598,7 @@ Swift 1.0
85628598[SE- 0300 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0300-continuation.md>
85638599[SE- 0306 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0306-actors.md>
85648600[SE- 0310 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0310-effectful-readonly-properties.md>
8601+ [SE- 0311 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0311-task-locals.md>
85658602[SE- 0313 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0313-actor-isolation-control.md>
85668603[SE- 0316 ]: < https: // github.com/apple/swift-evolution/blob/main/proposals/0316-global-actors.md>
85678604
0 commit comments