summaryrefslogtreecommitdiff
path: root/src/library/scala/concurrent/impl/ExecutionContextImpl.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/library/scala/concurrent/impl/ExecutionContextImpl.scala')
-rw-r--r--src/library/scala/concurrent/impl/ExecutionContextImpl.scala15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/library/scala/concurrent/impl/ExecutionContextImpl.scala b/src/library/scala/concurrent/impl/ExecutionContextImpl.scala
index 7b44d02612..7984aa02b7 100644
--- a/src/library/scala/concurrent/impl/ExecutionContextImpl.scala
+++ b/src/library/scala/concurrent/impl/ExecutionContextImpl.scala
@@ -11,20 +11,25 @@ package scala.concurrent.impl
import java.util.concurrent.{Callable, ExecutorService}
+import scala.concurrent.forkjoin._
import scala.concurrent.{ExecutionContext, resolver, Awaitable, body2awaitable}
import scala.util.{ Duration, Try, Success, Failure }
import scala.collection.mutable.Stack
-class ExecutionContextImpl(executorService: ExecutorService) extends ExecutionContext {
+class ExecutionContextImpl(val executorService: AnyRef) extends ExecutionContext {
import ExecutionContextImpl._
def execute(runnable: Runnable): Unit = executorService match {
- // case fj: ForkJoinPool =>
- // TODO fork if more applicable
- // executorService execute runnable
- case _ =>
+ case fj: ForkJoinPool =>
+ if (Thread.currentThread.isInstanceOf[ForkJoinWorkerThread]) {
+ val fjtask = ForkJoinTask.adapt(runnable)
+ fjtask.fork
+ } else {
+ fj.execute(runnable)
+ }
+ case executorService: ExecutorService =>
executorService execute runnable
}