future - Scala - ScheduledFuture -


i trying implement scheduled future in scala. wait specific time , execute body. far tried following, simple approach

val d = 5.seconds.fromnow  val f = future {await.ready(promise().future, d.timeleft); 1}  val res = await.result(f, duration.inf) 

but getting timeoutexcpetion on future. correct approach or should use scheduledexecutor java?

you change code this:

val d = 5.seconds.fromnow val f = future {delay(d); 1} val res = await.result(f, duration.inf)  def delay(dur:deadline) = {   try(await.ready(promise().future, dur.timeleft)) } 

but not recommend it. in doing so, blocking in future (blocking wait promise never complete), , think blocking in executioncontext discouraged. either using java scheduled executor stated or using akka @alex23 recommended.


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -