package concurrent
Common constants, factory methods and objects used throughout OPAL when performing concurrent computations.
- Alphabetic
- By Inheritance
- concurrent
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
- class ConcurrentExceptions extends Exception
-
final
class
ConcurrentTasks[T] extends Tasks[T]
Executes the given function
processfor each submitted value of typeT.Executes the given function
processfor each submitted value of typeT. Theprocessfunction can add further values that should be processed.val tasks = new Tasks[T] { (tasks : Tasks[T], t : T) ⇒ // do something with t if (<some condition>) { tasks.submit(nextT) } } val exceptions = tasks.join()
Example: -
trait
Locking extends AnyRef
A basic facility to model shared and exclusive access to some functionality/data structure.
A basic facility to model shared and exclusive access to some functionality/data structure.
Usage
To use this generic locking facility you should mix in this trait.
-
class
OPALThreadPoolExecutor extends ThreadPoolExecutor
A ThreadPool that knows the
ThreadGroupassociated with its threads and that catches exceptions if a thread crashes and reports them using the OPALLogger facility. -
final
class
SequentialTasks[T] extends Tasks[T]
- T
Type of the processed data.
- sealed trait Tasks[T] extends AnyRef
Value Members
- def ExecutionContextN(n: Int): ExecutionContext
-
final
val
NumberOfThreadsForCPUBoundTasks: Int
The number of threads that should be used by parallelized computations that are CPU bound (which do not use IO).
The number of threads that should be used by parallelized computations that are CPU bound (which do not use IO). This number is always larger than 0. This number is intended to reflect the number of physical cores (not hyperthreaded ones).
-
final
val
NumberOfThreadsForIOBoundTasks: Int
The size of the thread pool used by OPAL for IO bound tasks.
The size of the thread pool used by OPAL for IO bound tasks. The size should be at least as large as the number of physical cores and is ideally between 1 and 3 times larger than the number of (hyperthreaded) cores. This enables the efficient execution of IO bound tasks.
-
implicit final
val
OPALExecutionContext: ExecutionContext
The ExecutionContext used by OPAL.
The ExecutionContext used by OPAL.
This
ExecutionContextmust not be shutdown. - final val OPALExecutionContextTaskSupport: ExecutionContextTaskSupport
-
final
val
ThreadPool: OPALThreadPoolExecutor
Returns the singleton instance of the global
ThreadPoolused throughout OPAL. - def ThreadPoolN(n: Int): OPALThreadPoolExecutor
- final val defaultIsInterrupted: () ⇒ Boolean
- final def handleUncaughtException(t: Thread, e: Throwable): Unit
- final def handleUncaughtException(t: Throwable): Unit
-
def
parForeachArrayElement[T, U](data: Array[T], parallelizationLevel: Int = NumberOfThreadsForCPUBoundTasks, isInterrupted: () ⇒ Boolean = ...)(f: Function[T, U]): Unit
Execute the given function
fin parallel for each element of the given array.Execute the given function
fin parallel for each element of the given array. After processing an element it is checked whether the computation should be aborted.In general – but also at most –
parallelizationLevelmany threads will be used to process the elements. The core idea is that each thread processes an element and after that grabs the next element from the array. Hence, this handles situations gracefully where the effort necessary to analyze a specific element varies widely.- Annotations
- @throws( ... )
- Exceptions thrown
ConcurrentExceptionsif any exception occurs; the thrown exception stores all other exceptions (getSuppressed)- Note
The given function
,fmust not make use of non-local returns; such returns will be caught and reported later.The OPALExecutionContext is used for getting the necessary threads.
-
object
Locking
Defines several convenience methods related to using
(Reentrant(ReadWrite))Locks. -
object
Tasks
Factory to create Tasks objects to process value oriented tasks.