Skip to content

Instantly share code, notes, and snippets.

@abh1nav
Created August 29, 2014 04:15
Show Gist options
  • Save abh1nav/afac61b2fa588dd232a0 to your computer and use it in GitHub Desktop.
Save abh1nav/afac61b2fa588dd232a0 to your computer and use it in GitHub Desktop.
Zip with Index
// Trying to debug an actor system where workers are spawned from a list of work objects
// and only some workers exit cleanly while others crash
case class Work(...)
val workload = List[Work](...)
workload.zipWithIndex.foreach({
case (work, index) =>
val worker = context.actorOf(Props[WorkActor], s"worker$index")
worker ! work
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment