Skip to content

Commit

Permalink
Merge pull request #9270 from dwijnand/revert-batching-global
Browse files Browse the repository at this point in the history
Revert ExecutionContext.global to not be a BatchingExecutor
  • Loading branch information
lrytz committed Oct 23, 2020
2 parents 59c6eda + a5fb116 commit 79b4579
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions src/library/scala/concurrent/impl/ExecutionContextImpl.scala
Expand Up @@ -14,7 +14,7 @@ package scala.concurrent.impl

import java.util.concurrent.{ Semaphore, ForkJoinPool, ForkJoinWorkerThread, Callable, Executor, ExecutorService, ThreadFactory, TimeUnit }
import java.util.Collection
import scala.concurrent.{ Batchable, BatchingExecutor, BlockContext, ExecutionContext, CanAwait, ExecutionContextExecutor, ExecutionContextExecutorService }
import scala.concurrent.{ BlockContext, ExecutionContext, CanAwait, ExecutionContextExecutor, ExecutionContextExecutorService }

private[scala] class ExecutionContextImpl private[impl] (final val executor: Executor, final val reporter: Throwable => Unit) extends ExecutionContextExecutor {
require(executor ne null, "Executor must not be null")
Expand Down Expand Up @@ -98,15 +98,7 @@ private[concurrent] object ExecutionContextImpl {
prefix = "scala-execution-context-global",
uncaught = (thread: Thread, cause: Throwable) => reporter(cause))

new ForkJoinPool(desiredParallelism, threadFactory, threadFactory.uncaught, true) with ExecutionContextExecutorService with BatchingExecutor {
final override def submitForExecution(runnable: Runnable): Unit = super[ForkJoinPool].execute(runnable)

final override def execute(runnable: Runnable): Unit =
if ((!runnable.isInstanceOf[Promise.Transformation[_,_]] || runnable.asInstanceOf[Promise.Transformation[_,_]].benefitsFromBatching) && runnable.isInstanceOf[Batchable])
submitAsyncBatched(runnable)
else
submitForExecution(runnable)

new ForkJoinPool(desiredParallelism, threadFactory, threadFactory.uncaught, true) with ExecutionContextExecutorService {
final override def reportFailure(cause: Throwable): Unit =
getUncaughtExceptionHandler() match {
case null =>
Expand Down

0 comments on commit 79b4579

Please sign in to comment.