@@ -55,7 +55,7 @@ class Future[+T](body: Async ?=> T):
55
55
/** Wait for this future to be completed, return its value in case of success,
56
56
* or rethrow exception in case of failure.
57
57
*/
58
- def await (using a : Async ): T = a .await(this ).get
58
+ def value (using async : Async ): T = async .await(this ).get
59
59
60
60
// a handler for Async
61
61
private def async (body : Async ?=> Unit ): Unit =
@@ -186,8 +186,8 @@ object Future:
186
186
val f1 = Future (body1).linked
187
187
val f2 = Future (body2).linked
188
188
async.awaitEither(f1, f2) match
189
- case Left (Success (x1)) => (x1, f2.await )
190
- case Right (Success (x2)) => (f1.await , x2)
189
+ case Left (Success (x1)) => (x1, f2.value )
190
+ case Right (Success (x2)) => (f1.value , x2)
191
191
case Left (Failure (ex)) => throw ex
192
192
case Right (Failure (ex)) => throw ex
193
193
@@ -202,13 +202,13 @@ object Future:
202
202
async.awaitEither(f1, f2) match
203
203
case Left (Success (x1)) => x1
204
204
case Right (Success (x2)) => x2
205
- case Left (_ : Failure [? ]) => f2.await
206
- case Right (_ : Failure [? ]) => f1.await
205
+ case Left (_ : Failure [? ]) => f2.value
206
+ case Right (_ : Failure [? ]) => f1.value
207
207
end Future
208
208
209
209
def Test (x : Future [Int ], xs : List [Future [Int ]])(using Scheduler ): Future [Int ] =
210
210
Future .spawn:
211
- x.await + xs.map(_.await ).sum
211
+ x.value + xs.map(_.value ).sum
212
212
213
213
def Main (x : Future [Int ], xs : List [Future [Int ]])(using Scheduler ): Int =
214
214
Test (x, xs).force()
0 commit comments