Last active
January 16, 2018 21:41
-
-
Save JohnMurray/85072a9133733a8397126fa354ea68f2 to your computer and use it in GitHub Desktop.
A proper way to make a Future-wait (sleep) with Akka
This file contains hidden or 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
import akka.actor.ActorSystem | |
import akka.pattern.Patterns.after | |
import scala.concurrent.duration._ | |
val as = ActorSystem() | |
val x = after(2.seconds, as.scheduler, global, Future.successful(1)).flatMap { _ => | |
Future { | |
// long operation that _starts_ after the delayed future completes | |
1 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment