Feb
24th
Wed
24th
trival backgrounding with scala actors
A simple backgrounding object:
object BackgroundOperation {
def apply(f: => Unit) = {
BackgroundActor ! BackgroundJob(() => f)
}
case class BackgroundJob(f: () => Unit)
object BackgroundActor extends LiftActor {
protected def messageHandler = {
case BackgroundJob(f) => f()
}
}
}
Then you can do this whenever you want:
BackgroundOperation {
// some complicated thing
}