-
Notifications
You must be signed in to change notification settings - Fork 361
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add missing junit-async adaption for using Await.result
- Loading branch information
1 parent
baadd57
commit 2a71cff
Showing
1 changed file
with
9 additions
and
3 deletions.
There are no files selected for viewing
12 changes: 9 additions & 3 deletions
12
junit-async/native/src/main/scala/scala/scalanative/junit/async/package.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
package scala.scalanative.junit | ||
|
||
import scala.concurrent.Future | ||
import scala.concurrent.{Await, Future} | ||
import scala.concurrent.duration.Duration | ||
import scala.scalanative.meta.LinktimeInfo.isMultithreadingEnabled | ||
|
||
package object async { | ||
type AsyncResult = Unit | ||
def await(future: Future[_]): AsyncResult = { | ||
scala.scalanative.runtime.loop() | ||
future.value.get.get | ||
if (isMultithreadingEnabled) | ||
Await.result(future, Duration.Inf) | ||
else { | ||
scala.scalanative.runtime.loop() | ||
future.value.get.get | ||
} | ||
} | ||
} |