TaskSupport

scala.collection.parallel.TaskSupport
trait TaskSupport extends Tasks

A trait implementing the scheduling of a parallel collection operation.

Parallel collections are modular in the way operations are scheduled. Each parallel collection is parameterized with a task support object which is responsible for scheduling and load-balancing tasks to 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.

There are currently a few task support implementations available for parallel collections. The scala.collection.parallel.ForkJoinTaskSupport uses a fork-join pool internally.

The scala.collection.parallel.ExecutionContextTaskSupport uses the default execution context implementation found in scala.concurrent, and it reuses the thread pool used in scala.concurrent.

The execution context task support is set to each parallel collection by default, so parallel collections reuse the same fork-join pool as the future API.

Here is a way to change the task support of a parallel collection:

import scala.collection.parallel._
val pc = mutable.ParArray(1, 2, 3)
pc.tasksupport = new ForkJoinTaskSupport(
  new java.util.concurrent.ForkJoinPool(2))

Attributes

See also

Configuring Parallel Collections section on the parallel collection's guide for more information.

Graph
Supertypes
trait Tasks
class Object
trait Matchable
class Any
Known subtypes

Members list

Type members

Inherited classlikes

trait WrappedTask[R, +Tp]

Attributes

Inherited from:
Tasks
Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait AWSTWrappedTask[R, Tp]
class AWSFJTWrappedTask[R, Tp]
trait FJTWrappedTask[R, Tp]

Value members

Inherited and Abstract methods

def execute[R, Tp](fjtask: Task[R, Tp]): () => R

Executes a task and returns a future. Forwards an exception if some task threw it.

Executes a task and returns a future. Forwards an exception if some task threw it.

Attributes

Inherited from:
Tasks
def executeAndWaitResult[R, Tp](task: Task[R, Tp]): R

Executes a result task, waits for it to finish, then returns its result. Forwards an exception if some task threw it.

Executes a result task, waits for it to finish, then returns its result. Forwards an exception if some task threw it.

Attributes

Inherited from:
Tasks

Retrieves the parallelism level of the task execution environment.

Retrieves the parallelism level of the task execution environment.

Attributes

Inherited from:
Tasks

Inherited and Abstract fields

val environment: AnyRef

The type of the environment is more specific in the implementations.

The type of the environment is more specific in the implementations.

Attributes

Inherited from:
Tasks