@@ -60,10 +60,27 @@ extension Task {
60
60
/// If the task gets cancelled internally, e.g. by checking for cancellation
61
61
/// and throwing a specific error or using `checkCancellation` the error
62
62
/// thrown out of the task will be re-thrown here.
63
- public func get( ) async throws -> Success {
64
- return try await _taskFutureGetThrowing ( _task)
63
+ public var value : Success {
64
+ get async throws {
65
+ return try await _taskFutureGetThrowing ( _task)
66
+ }
65
67
}
66
68
69
+ /// Wait for the task to complete, returning (or throwing) its result.
70
+ ///
71
+ /// ### Priority
72
+ /// If the task has not completed yet, its priority will be elevated to the
73
+ /// priority of the current task. Note that this may not be as effective as
74
+ /// creating the task with the "right" priority to in the first place.
75
+ ///
76
+ /// ### Cancellation
77
+ /// If the awaited on task gets cancelled externally the `get()` will throw
78
+ /// a cancellation error.
79
+ ///
80
+ /// If the task gets cancelled internally, e.g. by checking for cancellation
81
+ /// and throwing a specific error or using `checkCancellation` the error
82
+ /// thrown out of the task will be re-thrown here.
83
+
67
84
/// Wait for the task to complete, returning its `Result`.
68
85
///
69
86
/// ### Priority
@@ -78,11 +95,13 @@ extension Task {
78
95
/// If the task gets cancelled internally, e.g. by checking for cancellation
79
96
/// and throwing a specific error or using `checkCancellation` the error
80
97
/// thrown out of the task will be re-thrown here.
81
- public func getResult( ) async -> Result < Success , Failure > {
82
- do {
83
- return . success( try await get ( ) )
84
- } catch {
85
- return . failure( error as! Failure ) // as!-safe, guaranteed to be Failure
98
+ public var result : Result < Success , Failure > {
99
+ get async {
100
+ do {
101
+ return . success( try await get ( ) )
102
+ } catch {
103
+ return . failure( error as! Failure ) // as!-safe, guaranteed to be Failure
104
+ }
86
105
}
87
106
}
88
107
@@ -114,8 +133,10 @@ extension Task where Failure == Never {
114
133
/// way than throwing a `CancellationError`, e.g. it could provide a neutral
115
134
/// value of the `Success` type, or encode that cancellation has occurred in
116
135
/// that type itself.
117
- public func get( ) async -> Success {
118
- return await _taskFutureGet ( _task)
136
+ public var value : Success {
137
+ get async {
138
+ return await _taskFutureGet ( _task)
139
+ }
119
140
}
120
141
}
121
142
0 commit comments