I want to check whether or not a Future f is completed right now by looking at a value its holding. That is not about
f onComplete {
}
It's about checking a value it's holding currently without blocking.
Your thoughts?
f.value match {
case Some(Success(x)) => println(s"the future is completed successfully with value $x")
case Some(Failure(e)) => println(s"the future failed with an error: $e")
case None => println("the future has not yet completed")
}
You can use value if it is None the Future is not completed. If it is Some some will contain the value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With