From f3e545489eec465226c1b4769194d52acb8b1caa Mon Sep 17 00:00:00 2001 From: Aleksandar Prokopec Date: Mon, 5 Mar 2012 13:40:55 +0100 Subject: Make task support implementations public. --- .../scala/collection/parallel/TaskSupport.scala | 26 +++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/library/scala/collection/parallel/TaskSupport.scala b/src/library/scala/collection/parallel/TaskSupport.scala index fc99347316..59b75f523f 100644 --- a/src/library/scala/collection/parallel/TaskSupport.scala +++ b/src/library/scala/collection/parallel/TaskSupport.scala @@ -17,18 +17,38 @@ import scala.concurrent.ExecutionContext +/** A trait implementing the scheduling of + * a parallel collection operation. + * + * Task support objects handle how a task is split and + * distributed across processors. A task support object can be + * changed in a parallel collection after it has been created, + * but only during a quiescent period, i.e. while there are no + * concurrent invocations to parallel collection methods. + */ trait TaskSupport extends Tasks -private[collection] class ForkJoinTaskSupport(val environment: ForkJoinPool = ForkJoinTasks.defaultForkJoinPool) +/** A task support that uses a fork join pool to schedule tasks */ +class ForkJoinTaskSupport(val environment: ForkJoinPool = ForkJoinTasks.defaultForkJoinPool) extends TaskSupport with AdaptiveWorkStealingForkJoinTasks -private[collection] class ThreadPoolTaskSupport(val environment: ThreadPoolExecutor = ThreadPoolTasks.defaultThreadPool) +/** A task support that uses a thread pool executor to schedule tasks */ +class ThreadPoolTaskSupport(val environment: ThreadPoolExecutor = ThreadPoolTasks.defaultThreadPool) extends TaskSupport with AdaptiveWorkStealingThreadPoolTasks -private[collection] class ExecutionContextTaskSupport(val environment: ExecutionContext = scala.concurrent.executionContext) +/** A task support that uses an execution context to schedule tasks. + * + * It can be used with the default execution context implementation in the `scala.concurrent` package. + * It internally forwards the call to either a forkjoin based task support or a thread pool executor one, + * depending on what the execution context uses. + * + * By default, parallel collections are parametrized with this task support object, so parallel collections + * share the same execution context backend as the rest of the `scala.concurrent` package. + */ +class ExecutionContextTaskSupport(val environment: ExecutionContext = scala.concurrent.executionContext) extends TaskSupport with ExecutionContextTasks -- cgit v1.2.3