File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
library/src/scala/concurrent Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -191,8 +191,10 @@ package concurrent {
191
191
*/
192
192
@ throws(classOf [TimeoutException ])
193
193
@ throws(classOf [InterruptedException ])
194
- def ready [T ](awaitable : Awaitable [T ], atMost : Duration ): awaitable.type =
195
- blocking(awaitable.ready(atMost)(AwaitPermission ))
194
+ def ready [T ](awaitable : Awaitable [T ], atMost : Duration ): awaitable.type = awaitable match {
195
+ case f : Future [T ] if f.isCompleted => awaitable.ready(atMost)(AwaitPermission )
196
+ case _ => blocking(awaitable.ready(atMost)(AwaitPermission ))
197
+ }
196
198
197
199
/**
198
200
* Await and return the result (of type `T`) of an `Awaitable`.
@@ -216,7 +218,9 @@ package concurrent {
216
218
*/
217
219
@ throws(classOf [TimeoutException ])
218
220
@ throws(classOf [InterruptedException ])
219
- def result [T ](awaitable : Awaitable [T ], atMost : Duration ): T =
220
- blocking(awaitable.result(atMost)(AwaitPermission ))
221
+ def result [T ](awaitable : Awaitable [T ], atMost : Duration ): T = awaitable match {
222
+ case f : Future [_] if f.isCompleted => awaitable.result(atMost)(AwaitPermission )
223
+ case _ => blocking(awaitable.result(atMost)(AwaitPermission ))
224
+ }
221
225
}
222
226
}
You can’t perform that action at this time.
0 commit comments