Class ForkJoinPoolHierarchicalTestExecutorService
- java.lang.Object
-
- org.junit.platform.engine.support.hierarchical.ForkJoinPoolHierarchicalTestExecutorService
-
- All Implemented Interfaces:
java.lang.AutoCloseable,HierarchicalTestExecutorService
@API(status=STABLE, since="1.10") public class ForkJoinPoolHierarchicalTestExecutorService extends java.lang.Object implements HierarchicalTestExecutorService- Since:
- 1.3
- See Also:
ForkJoinPool,DefaultParallelExecutionConfigurationStrategy
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) classForkJoinPoolHierarchicalTestExecutorService.ExclusiveTask(package private) static interfaceForkJoinPoolHierarchicalTestExecutorService.TaskEventListener(package private) static classForkJoinPoolHierarchicalTestExecutorService.ThreadLock(package private) static classForkJoinPoolHierarchicalTestExecutorService.WorkerThread(package private) static classForkJoinPoolHierarchicalTestExecutorService.WorkerThreadFactory-
Nested classes/interfaces inherited from interface org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutorService
HierarchicalTestExecutorService.TestTask
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.util.concurrent.ForkJoinPoolforkJoinPoolprivate intparallelismprivate ForkJoinPoolHierarchicalTestExecutorService.TaskEventListenertaskEventListenerprivate java.lang.ThreadLocal<ForkJoinPoolHierarchicalTestExecutorService.ThreadLock>threadLocks
-
Constructor Summary
Constructors Constructor Description ForkJoinPoolHierarchicalTestExecutorService(ConfigurationParameters configurationParameters)Create a newForkJoinPoolHierarchicalTestExecutorServicebased on the suppliedConfigurationParameters.ForkJoinPoolHierarchicalTestExecutorService(ParallelExecutionConfiguration configuration)Create a newForkJoinPoolHierarchicalTestExecutorServicebased on the suppliedParallelExecutionConfiguration.ForkJoinPoolHierarchicalTestExecutorService(ParallelExecutionConfiguration configuration, ForkJoinPoolHierarchicalTestExecutorService.TaskEventListener taskEventListener)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close this service and let it perform any required cleanup work.private static ParallelExecutionConfigurationcreateConfiguration(ConfigurationParameters configurationParameters)private java.util.concurrent.ForkJoinPoolcreateForkJoinPool(ParallelExecutionConfiguration configuration)private voidexecuteSync(java.util.Deque<ForkJoinPoolHierarchicalTestExecutorService.ExclusiveTask> tasks)private voidforkConcurrentTasks(java.util.List<? extends HierarchicalTestExecutorService.TestTask> tasks, java.util.Deque<ForkJoinPoolHierarchicalTestExecutorService.ExclusiveTask> isolatedTasks, java.util.Deque<ForkJoinPoolHierarchicalTestExecutorService.ExclusiveTask> sameThreadTasks, java.util.Deque<ForkJoinPoolHierarchicalTestExecutorService.ExclusiveTask> concurrentTasksInReverseOrder)voidinvokeAll(java.util.List<? extends HierarchicalTestExecutorService.TestTask> tasks)Invoke all supplied test tasks and block until their execution has finished.private booleanisAlreadyRunningInForkJoinPool()private voidjoinConcurrentTasksInReverseOrderToEnableWorkStealing(java.util.Deque<ForkJoinPoolHierarchicalTestExecutorService.ExclusiveTask> concurrentTasksInReverseOrder)private static booleanrequiresGlobalReadWriteLock(HierarchicalTestExecutorService.TestTask testTask)private voidresubmitDeferredTasks()private static java.util.concurrent.Callable<java.util.concurrent.ForkJoinPool>sinceJava7ConstructorInvocation(ParallelExecutionConfiguration configuration, java.util.concurrent.ForkJoinPool.ForkJoinWorkerThreadFactory threadFactory)private static java.util.Optional<java.lang.reflect.Constructor<java.util.concurrent.ForkJoinPool>>sinceJava9Constructor()private static java.util.function.Function<java.lang.reflect.Constructor<java.util.concurrent.ForkJoinPool>,java.util.concurrent.Callable<java.util.concurrent.ForkJoinPool>>sinceJava9ConstructorInvocation(ParallelExecutionConfiguration configuration, java.util.concurrent.ForkJoinPool.ForkJoinWorkerThreadFactory threadFactory)java.util.concurrent.Future<java.lang.Void>submit(HierarchicalTestExecutorService.TestTask testTask)Submit the supplied test task to be executed by this service.
-
-
-
Field Detail
-
forkJoinPool
final java.util.concurrent.ForkJoinPool forkJoinPool
-
taskEventListener
private final ForkJoinPoolHierarchicalTestExecutorService.TaskEventListener taskEventListener
-
parallelism
private final int parallelism
-
threadLocks
private final java.lang.ThreadLocal<ForkJoinPoolHierarchicalTestExecutorService.ThreadLock> threadLocks
-
-
Constructor Detail
-
ForkJoinPoolHierarchicalTestExecutorService
public ForkJoinPoolHierarchicalTestExecutorService(ConfigurationParameters configurationParameters)
Create a newForkJoinPoolHierarchicalTestExecutorServicebased on the suppliedConfigurationParameters.
-
ForkJoinPoolHierarchicalTestExecutorService
@API(status=STABLE, since="1.10") public ForkJoinPoolHierarchicalTestExecutorService(ParallelExecutionConfiguration configuration)Create a newForkJoinPoolHierarchicalTestExecutorServicebased on the suppliedParallelExecutionConfiguration.- Since:
- 1.7
-
ForkJoinPoolHierarchicalTestExecutorService
ForkJoinPoolHierarchicalTestExecutorService(ParallelExecutionConfiguration configuration, ForkJoinPoolHierarchicalTestExecutorService.TaskEventListener taskEventListener)
-
-
Method Detail
-
createConfiguration
private static ParallelExecutionConfiguration createConfiguration(ConfigurationParameters configurationParameters)
-
createForkJoinPool
private java.util.concurrent.ForkJoinPool createForkJoinPool(ParallelExecutionConfiguration configuration)
-
sinceJava9Constructor
private static java.util.Optional<java.lang.reflect.Constructor<java.util.concurrent.ForkJoinPool>> sinceJava9Constructor()
-
sinceJava9ConstructorInvocation
private static java.util.function.Function<java.lang.reflect.Constructor<java.util.concurrent.ForkJoinPool>,java.util.concurrent.Callable<java.util.concurrent.ForkJoinPool>> sinceJava9ConstructorInvocation(ParallelExecutionConfiguration configuration, java.util.concurrent.ForkJoinPool.ForkJoinWorkerThreadFactory threadFactory)
-
sinceJava7ConstructorInvocation
private static java.util.concurrent.Callable<java.util.concurrent.ForkJoinPool> sinceJava7ConstructorInvocation(ParallelExecutionConfiguration configuration, java.util.concurrent.ForkJoinPool.ForkJoinWorkerThreadFactory threadFactory)
-
submit
public java.util.concurrent.Future<java.lang.Void> submit(HierarchicalTestExecutorService.TestTask testTask)
Description copied from interface:HierarchicalTestExecutorServiceSubmit the supplied test task to be executed by this service.Implementations may execute the task asynchronously as long as its execution mode is concurrent.
Implementations must generally acquire and release the task's resource lock before and after its execution unless they execute all tests in the same thread which upholds the same guarantees.
- Specified by:
submitin interfaceHierarchicalTestExecutorService- Parameters:
testTask- the test task to be executed- Returns:
- a future that the caller can use to wait for the task's execution to be finished
- See Also:
HierarchicalTestExecutorService.invokeAll(List)
-
isAlreadyRunningInForkJoinPool
private boolean isAlreadyRunningInForkJoinPool()
-
invokeAll
public void invokeAll(java.util.List<? extends HierarchicalTestExecutorService.TestTask> tasks)
Description copied from interface:HierarchicalTestExecutorServiceInvoke all supplied test tasks and block until their execution has finished.Implementations may execute one or multiple of the supplied tasks in parallel as long as their execution mode is concurrent.
Implementations must generally acquire and release each task's resource lock before and after its execution unless they execute all tests in the same thread which upholds the same guarantees.
- Specified by:
invokeAllin interfaceHierarchicalTestExecutorService- Parameters:
tasks- the test tasks to be executed- See Also:
HierarchicalTestExecutorService.submit(TestTask)
-
forkConcurrentTasks
private void forkConcurrentTasks(java.util.List<? extends HierarchicalTestExecutorService.TestTask> tasks, java.util.Deque<ForkJoinPoolHierarchicalTestExecutorService.ExclusiveTask> isolatedTasks, java.util.Deque<ForkJoinPoolHierarchicalTestExecutorService.ExclusiveTask> sameThreadTasks, java.util.Deque<ForkJoinPoolHierarchicalTestExecutorService.ExclusiveTask> concurrentTasksInReverseOrder)
-
requiresGlobalReadWriteLock
private static boolean requiresGlobalReadWriteLock(HierarchicalTestExecutorService.TestTask testTask)
-
executeSync
private void executeSync(java.util.Deque<ForkJoinPoolHierarchicalTestExecutorService.ExclusiveTask> tasks)
-
joinConcurrentTasksInReverseOrderToEnableWorkStealing
private void joinConcurrentTasksInReverseOrderToEnableWorkStealing(java.util.Deque<ForkJoinPoolHierarchicalTestExecutorService.ExclusiveTask> concurrentTasksInReverseOrder)
-
resubmitDeferredTasks
private void resubmitDeferredTasks()
-
close
public void close()
Description copied from interface:HierarchicalTestExecutorServiceClose this service and let it perform any required cleanup work.For example, thread-based implementations should usually close their thread pools in this method.
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfaceHierarchicalTestExecutorService
-
-