Scala Programming Language
  1. Scala Programming Language
  2. SI-7861

Regression in use of Future InternalExecutor

    Details

      Description

      % git show da54f34a6526b --stat
      commit da54f34a6526b49b9e13e60c4fce242325c1c36e
      Author: Viktor Klang <viktor.klang@gmail.com>
      Date:   Wed Jun 19 23:16:53 2013 +0200
      
          Cleaning up method implementations in Future
              Optimizations:
              1) Avoiding isDefinedAt + apply and using applyOrElse to allow for optimizations later
              2) Reducing method sizes to be more JIT + inliner friendly
              3) Reusing core combinators to reuse inliner/JIT optimizations and be more code-cache friendly
      
       src/library/scala/concurrent/Future.scala | 181 ++++++++++++++++++++---------------------------------------------------------------
       1 file changed, 44 insertions(+), 137 deletions(-)
      
      % scala-hash da54f34a6526b~1 test/files/run/future-flatmap-exec-count.scala
      [info] da54f34a65 => /Users/jason/usr/scala-v2.10.1-318-g70e2ead
      execute()
      called continuation
      
      % scala-hash da54f34a6526b test/files/run/future-flatmap-exec-count.scala
      [info] da54f34a65 => /Users/jason/usr/scala-v2.10.1-319-gda54f34
      execute()
      called continuation
      execute()
      
      % cat test/files/run/future-flatmap-exec-count.scala
      import scala.concurrent._
      import java.util.concurrent.atomic.AtomicInteger
      
      object Test {
        def main(args: Array[String]) {
          test()
        }
      
        def test() = {
          val p = Promise[Int]()
          val fp = p.future
          val ec = new TestExecutionContext(ExecutionContext.Implicits.global)
      
          val flatMapped = fp.flatMap({ (x: Int) =>
            println("called continuation")
            Future.successful(2 * x)
          })(ec)
          p.success(111)
          Await.result(flatMapped, duration.Duration.Inf)
        }
      
        class TestExecutionContext(delegate: ExecutionContext) extends ExecutionContext {
          def execute(runnable: Runnable): Unit = ???
      
          def reportFailure(t: Throwable): Unit = ???
      
          override def prepare(): ExecutionContext = {
            val preparedDelegate = delegate.prepare()
            return new ExecutionContext {
              def execute(runnable: Runnable): Unit = {
                println("execute()")
                preparedDelegate.execute(runnable)
              }
      
              def reportFailure(t: Throwable): Unit = ???
            }
          }
        }
      }
      
      

        Activity

        Show
        Jason Zaugg added a comment - https://github.com/scala/scala/pull/2969

          People

          • Assignee:
            Jason Zaugg
            Reporter:
            Jason Zaugg
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development