Skip to content

Instantly share code, notes, and snippets.

@andyczerwonka
Last active January 1, 2016 15:28
Show Gist options
  • Save andyczerwonka/8164100 to your computer and use it in GitHub Desktop.
Save andyczerwonka/8164100 to your computer and use it in GitHub Desktop.
import akka.actor.{Actor, Stash}
class PausableWorker extends Actor with Stash {
def receive = processing
def processing: Receive = {
case "pause" => context.become(paused)
case msg => // Process task
}
def paused: Receive = {
case "resume" =>
unstashAll()
context.unbecome()
case msg =>
stash()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment