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

Re: [akka-user] [continuations plugin] Can I use reify and ControlContext directly?

No replies
Joshua.Suereth
Joined: 2008-09-02,
User offline. Last seen 32 weeks 5 days ago.
This was cross-posted to scala-user, so answering there as well.

On Sun, Jan 29, 2012 at 10:05 AM, Josh Suereth <joshua.suereth@gmail.com> wrote:
You should not see any issues with those methods.  The continuations plugin is actually transforming your code to use ControlContext directly.  reify and its friends should compile to no-ops.  They exist only to appease the type system before the code rewrites happen.
- Josh

On Sat, Jan 28, 2012 at 11:52 AM, IL <iron9light@gmail.com> wrote:
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