This page is no longer maintained — Please continue to the home page at www.scala-lang.org

[continuations plugin] Can I use reify and ControlContext directly?

No replies
iron9light
Joined: 2009-07-04,
User offline. Last seen 3 years 15 weeks ago.
Will I lose any performance optimization?Here's my code (with akka 2.0-M3): 
import util.continuations._import akka.dispatch.{ExecutionContext, Promise}
object AsFuture {  def apply[T](ctx: => T@suspendable)(implicit executor: ExecutionContext) = {    val ctxR = reify[T,Unit,Unit](ctx)    if (ctxR.isTrivial)      Promise.successful(ctxR.getTrivialValue.asInstanceOf[T])    else {      val promise = Promise[T]()      ctxR.foreachFull(promise.success(_), promise.failure(_))      promise    }  }}

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland