Skip to content

Instantly share code, notes, and snippets.

@Krasnyanskiy
Last active July 9, 2016 10:34
Show Gist options
  • Save Krasnyanskiy/502a6adc8966e9553f5a74e1bf0617e5 to your computer and use it in GitHub Desktop.
Save Krasnyanskiy/502a6adc8966e9553f5a74e1bf0617e5 to your computer and use it in GitHub Desktop.
-scala: akka: PF.empty test
import akka.actor.{Actor, ActorSystem, Props}
import akka.util.Timeout
import akka.pattern.ask
import scala.concurrent.duration._
implicit val timeout = Timeout(2.seconds)
class Loafer extends Actor {
// def receive = PartialFunction.empty
def receive = {
case _ => sender ! "oh, I have a story!"
}
}
val slackie = ActorSystem("Slackie")
val lf = slackie.actorOf(Props[Loafer], "loafer")
val answer = Await.result(
lf ? "What's up, loafer?", 2.seconds
).asInstanceOf[String]
println(answer)
slackie shutdown()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment