commons-continuations is a collection of utilities which is designed to help Scala programmers to work with continuations.
import com.dongxiguo.commons.continuations.CollectionConverters._
import scala.util.continuations.shiftUnit
val mySeq = Seq("foo", "bar", "baz")
val results = for (element in mySeq.asSuspendable.par) yield {
shiftUnit("Result from a suspendable expression: " + element)
}
import com.dongxiguo.commons.continuations.Hang
import scala.util.continuations.shift
shift(Hang)
import com.dongxiguo.commons.continuations.Label
val repeatPoint = Label()
doSomething()
repeatePoint.goto() // Infinite loop
See AsynchronousInputStream and SocketWritingQueue.
If you use Sbt, add following lines to you build.sbt
:
libraryDependencies += "com.dongxiguo" %% "commons-continuations" % "0.2.2"
Note that commons-continuations
requires Scala version 2.10.x
or 2.11.x
.