ConcurrentTaskUtil

io.joern.x2cpg.utils.ConcurrentTaskUtil

A utility for providing out-of-the-box basic concurrent execution for a collection of Scala functions.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def runUsingSpliterator[V](tasks: Iterator[() => V]): List[Try[V]]

Uses a Spliterator to run a number of tasks in parallel, where any number of threads may be alive at any point. This is useful for running a large number of tasks with low memory consumption. Spliterator's default thread pool is ForkJoinPool.commonPool().

Uses a Spliterator to run a number of tasks in parallel, where any number of threads may be alive at any point. This is useful for running a large number of tasks with low memory consumption. Spliterator's default thread pool is ForkJoinPool.commonPool().

Type parameters

V

the output type of each task.

Value parameters

tasks

the tasks to parallelize.

Attributes

Returns

an array of the executed tasks as either a success or failure.

def runUsingThreadPool[V](tasks: Iterator[() => V], maxPoolSize: Int): List[Try[V]]

Uses a thread pool with a limited number of active threads executing a task at any given point. This is effective when tasks may require large amounts of memory, or single tasks are too short lived.

Uses a thread pool with a limited number of active threads executing a task at any given point. This is effective when tasks may require large amounts of memory, or single tasks are too short lived.

Type parameters

V

the output type of each task.

Value parameters

maxPoolSize

the max pool size to allow for active threads.

tasks

the tasks to parallelize.

Attributes

Returns

an array of the executed tasks as either a success or failure.