Last active
January 1, 2016 15:28
-
-
Save andyczerwonka/8164100 to your computer and use it in GitHub Desktop.
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.{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