Skip to content

Commit d1443e9

Browse files
committed
Revert "refine API specifications"
This reverts commit 53231c7.
1 parent 53231c7 commit d1443e9

File tree

1 file changed

+19
-23
lines changed

1 file changed

+19
-23
lines changed

proposals/0454-task-naming-api.md

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,21 @@ By introducing this in a structured, coherent way in Swift itself, rather than d
4848

4949
## Detailed design
5050

51+
5152
Naming tasks is only allowed during their creation, and modifying names is not allowed. Names are arbitrary user-defined strings, which may be computed at runtime because they often contain identifying information such as the request ID or similar runtime information.
5253

5354
In order to allow naming tasks, the following APIs will be provided on `Task`:
5455

5556
```swift
56-
init(
57-
name: String? = nil,
58-
executorPreference taskExecutor: (any TaskExecutor)? = nil,
59-
operation: sending @escaping @isolated(any) () async -> Success
60-
)
61-
62-
static func detached(
63-
name: String? = nil,
64-
executorPreference taskExecutor: (any TaskExecutor)? = nil,
65-
operation: sending @escaping @isolated(any) () async -> Success
66-
)
57+
init(
58+
name: String? = nil,
59+
priority: TaskPriority? = nil,
60+
operation: sending @escaping @isolated(any) () async -> Success
61+
62+
static func detached(
63+
name: String? = nil,
64+
priority: TaskPriority? = nil,
65+
operation: sending @escaping @isolated(any) () async -> Success
6766
```
6867

6968
In addition to these APIs to name unstructured Tasks, the following API will be added to name Tasks created as a part of a task group task group:
@@ -74,14 +73,15 @@ mutating func addTask(
7473
executorPreference taskExecutor: (any TaskExecutor)? = nil,
7574
priority: TaskPriority? = nil,
7675
operation: sending @escaping @isolated(any) () async -> ChildTaskResult
77-
)
76+
)
7877

79-
mutating func addTaskUnlessCancelled(
80-
name: String? = nil,
81-
executorPreference taskExecutor: (any TaskExecutor)? = nil,
82-
priority: TaskPriority? = nil,
83-
operation: sending @escaping @isolated(any) () async -> ChildTaskResult
84-
)
78+
mutating func addTaskUnlessCancelled(
79+
name: String? = nil,
80+
executorPreference taskExecutor: (any TaskExecutor)? = nil,
81+
priority: TaskPriority? = nil,
82+
operation: sending @escaping @isolated(any) () async -> ChildTaskResult
83+
)
84+
8585
```
8686

8787
These APIs would be added to all kinds of task groups, including throwing, discarding ones. With the signature being appropriately matching the existing addTask signatures of those groups
@@ -90,11 +90,7 @@ In addition to that, it will be possible to read a name off a task, similar to h
9090

9191
```swift
9292
extension Task {
93-
// read the name of a task instance, e.g. someTask.name
94-
var name: String? { get }
95-
96-
// read the name of the current task, e.g. Task.name
97-
static var currentName: String? { get }
93+
var currentName: String? { get }
9894
}
9995
```
10096

0 commit comments

Comments
 (0)