Last active
December 18, 2015 17:59
-
-
Save jastice/5822953 to your computer and use it in GitHub Desktop.
This file contains 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
class IntegrationSuite extends FunSuite with ShouldMatchers { | |
test("infinit actor") { | |
val actor= ActorSystem("tail").actorOf(Props[MrActor]) | |
Thread.sleep(10000) | |
actor ! Interrupt | |
Thread.sleep(40054) | |
} | |
class MrActor extends Actor { | |
lazy val ps: Stream[Int] = 2 #:: Stream.from(3).filter(i => ps.takeWhile(j => j * j <= i).forall(i % _ > 0)) | |
override def preStart = { | |
self ! Work(ps) | |
} | |
override def receive = working | |
def working: Receive = { | |
case Interrupt => become interrupted | |
case Work(ps) => | |
val h = ps.head | |
// process somehow | |
self ! Work(ps.tail) | |
} | |
def interrupted: Receive = { | |
case Work(ps) => // ignore? | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment