Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[nomaster] refactor AdaptedForkJoinTask, uncaughtExceptionHandler

Inlined AdaptedForkJoinTask, made uncaughtExceptionHandler private[this].

This is necessary to maintain binary compatibility with 2.10.0.
  • Loading branch information...
commit 9194b37a8d402b67e41e941fddb4a741bf8eb16f 1 parent 56cbf23
@adriaanm adriaanm authored
View
20 bincompat-forward.whitelist.conf
@@ -44,16 +44,16 @@ filter {
# matchName="scala.concurrent.BatchingExecutor"
# problemName=MissingClassProblem
# },
- {
- # private[concurrent]
- matchName="scala.concurrent.impl.ExecutionContextImpl$AdaptedForkJoinTask"
- problemName=MissingClassProblem
- },
- {
- # private[concurrent]
- matchName="scala.concurrent.impl.ExecutionContextImpl.scala$concurrent$impl$ExecutionContextImpl$$uncaughtExceptionHandler"
- problemName=MissingMethodProblem
- },
+ # {
+ # # private[concurrent]
+ # matchName="scala.concurrent.impl.ExecutionContextImpl$AdaptedForkJoinTask"
+ # problemName=MissingClassProblem
+ # },
+ # {
+ # # private[concurrent]
+ # matchName="scala.concurrent.impl.ExecutionContextImpl.scala$concurrent$impl$ExecutionContextImpl$$uncaughtExceptionHandler"
+ # problemName=MissingMethodProblem
+ # },
{
# private nested class became private top-level class to fix SI-7018
matchName="scala.reflect.macros.NonemptyAttachments"
View
33 src/library/scala/concurrent/impl/ExecutionContextImpl.scala
@@ -25,7 +25,7 @@ private[scala] class ExecutionContextImpl private[impl] (es: Executor, reporter:
case some => some
}
- private val uncaughtExceptionHandler: Thread.UncaughtExceptionHandler = new Thread.UncaughtExceptionHandler {
+ private[this] val uncaughtExceptionHandler: Thread.UncaughtExceptionHandler = new Thread.UncaughtExceptionHandler {
def uncaughtException(thread: Thread, cause: Throwable): Unit = reporter(cause)
}
@@ -96,11 +96,24 @@ private[scala] class ExecutionContextImpl private[impl] (es: Executor, reporter:
}
}
+
def execute(runnable: Runnable): Unit = executor match {
case fj: ForkJoinPool =>
val fjt = runnable match {
case t: ForkJoinTask[_] => t
- case r => new ExecutionContextImpl.AdaptedForkJoinTask(r)
+ case runnable => new ForkJoinTask[Unit] {
+ final override def setRawResult(u: Unit): Unit = ()
+ final override def getRawResult(): Unit = ()
+ final override def exec(): Boolean = try { runnable.run(); true } catch {
+ case anything: Throwable
+ val t = Thread.currentThread
+ t.getUncaughtExceptionHandler match {
+ case null
+ case some some.uncaughtException(t, anything)
+ }
+ throw anything
+ }
+ }
}
Thread.currentThread match {
case fjw: ForkJoinWorkerThread if fjw.getPool eq fj => fjt.fork()
@@ -112,23 +125,7 @@ private[scala] class ExecutionContextImpl private[impl] (es: Executor, reporter:
def reportFailure(t: Throwable) = reporter(t)
}
-
private[concurrent] object ExecutionContextImpl {
-
- final class AdaptedForkJoinTask(runnable: Runnable) extends ForkJoinTask[Unit] {
- final override def setRawResult(u: Unit): Unit = ()
- final override def getRawResult(): Unit = ()
- final override def exec(): Boolean = try { runnable.run(); true } catch {
- case anything: Throwable
- val t = Thread.currentThread
- t.getUncaughtExceptionHandler match {
- case null
- case some some.uncaughtException(t, anything)
- }
- throw anything
- }
- }
-
def fromExecutor(e: Executor, reporter: Throwable => Unit = ExecutionContext.defaultReporter): ExecutionContextImpl = new ExecutionContextImpl(e, reporter)
def fromExecutorService(es: ExecutorService, reporter: Throwable => Unit = ExecutionContext.defaultReporter): ExecutionContextImpl with ExecutionContextExecutorService =
new ExecutionContextImpl(es, reporter) with ExecutionContextExecutorService {
Please sign in to comment.
Something went wrong with that request. Please try again.