- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Re: [akka-user] [continuations plugin] Can I use reify and ControlContext directly?
Sun, 2012-01-29, 16:06
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:
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 } }}