Add atMost parameter

This commit is contained in:
Eugene Yokota 2020-06-10 15:30:39 -04:00
parent b78e4f0919
commit c8f52e6281
1 changed files with 7 additions and 2 deletions

View File

@ -865,14 +865,19 @@ object Project extends ProjectExtra {
}
}
/** implicitly injected to tasks that return PromiseWrap.
*/
final class RichTaskPromise[A](i: Def.Initialize[Task[PromiseWrap[A]]]) {
import scala.concurrent.Await
import scala.concurrent.duration._
def await: Def.Initialize[Task[A]] =
def await: Def.Initialize[Task[A]] = await(Duration.Inf)
def await(atMost: Duration): Def.Initialize[Task[A]] =
(Def
.task {
val p = i.value
val result: A = Await.result(p.underlying.future, Duration.Inf)
val result: A = Await.result(p.underlying.future, atMost)
result
})
.tag(Tags.Sentinel)