@@ -87,10 +87,27 @@ extension Task {
87
87
/// If the task gets cancelled internally, e.g. by checking for cancellation
88
88
/// and throwing a specific error or using `checkCancellation` the error
89
89
/// thrown out of the task will be re-thrown here.
90
- public func get( ) async throws -> Success {
91
- return try await _taskFutureGetThrowing ( _task)
90
+ public var value : Success {
91
+ get async throws {
92
+ return try await _taskFutureGetThrowing ( _task)
93
+ }
92
94
}
93
95
96
+ /// Wait for the task to complete, returning (or throwing) its result.
97
+ ///
98
+ /// ### Priority
99
+ /// If the task has not completed yet, its priority will be elevated to the
100
+ /// priority of the current task. Note that this may not be as effective as
101
+ /// creating the task with the "right" priority to in the first place.
102
+ ///
103
+ /// ### Cancellation
104
+ /// If the awaited on task gets cancelled externally the `get()` will throw
105
+ /// a cancellation error.
106
+ ///
107
+ /// If the task gets cancelled internally, e.g. by checking for cancellation
108
+ /// and throwing a specific error or using `checkCancellation` the error
109
+ /// thrown out of the task will be re-thrown here.
110
+
94
111
/// Wait for the task to complete, returning its `Result`.
95
112
///
96
113
/// ### Priority
@@ -105,11 +122,13 @@ extension Task {
105
122
/// If the task gets cancelled internally, e.g. by checking for cancellation
106
123
/// and throwing a specific error or using `checkCancellation` the error
107
124
/// thrown out of the task will be re-thrown here.
108
- public func getResult( ) async -> Result < Success , Failure > {
109
- do {
110
- return . success( try await get ( ) )
111
- } catch {
112
- return . failure( error as! Failure ) // as!-safe, guaranteed to be Failure
125
+ public var result : Result < Success , Failure > {
126
+ get async {
127
+ do {
128
+ return . success( try await get ( ) )
129
+ } catch {
130
+ return . failure( error as! Failure ) // as!-safe, guaranteed to be Failure
131
+ }
113
132
}
114
133
}
115
134
@@ -142,8 +161,10 @@ extension Task where Failure == Never {
142
161
/// way than throwing a `CancellationError`, e.g. it could provide a neutral
143
162
/// value of the `Success` type, or encode that cancellation has occurred in
144
163
/// that type itself.
145
- public func get( ) async -> Success {
146
- return await _taskFutureGet ( _task)
164
+ public var value : Success {
165
+ get async {
166
+ return await _taskFutureGet ( _task)
167
+ }
147
168
}
148
169
}
149
170
0 commit comments