Class AbstractThreadPoolStrategy
java.lang.Object
org.apache.maven.surefire.junitcore.pc.SchedulingStrategy
org.apache.maven.surefire.junitcore.pc.AbstractThreadPoolStrategy
- All Implemented Interfaces:
Destroyable
- Direct Known Subclasses:
NonSharedThreadPoolStrategy
,SharedThreadPoolStrategy
Abstract parallel scheduling strategy in private package.
The remaining abstract methods have to be implemented differently
depending if the thread pool is shared with other strategies or not.
- Since:
- 2.16
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Collection<Future<?>>
private boolean
private final ExecutorService
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractThreadPoolStrategy
(ConsoleLogger logger, ExecutorService threadPool) AbstractThreadPoolStrategy
(ConsoleLogger logger, ExecutorService threadPool, Collection<Future<?>> futureResults) -
Method Summary
Modifier and TypeMethodDescriptionboolean
destroy()
protected final Collection<Future<?>>
protected final ExecutorService
void
Schedules tasks ifSchedulingStrategy.canSchedule()
.protected void
protected boolean
stop()
Stops scheduling new tasks (e.g.protected boolean
stopNow()
Stops scheduling new tasks andinterrupts
running tasks (e.g.Methods inherited from class org.apache.maven.surefire.junitcore.pc.SchedulingStrategy
canSchedule, disable, finished, hasSharedThreadPool, logQuietly
-
Field Details
-
threadPool
-
futureResults
-
isDestroyed
private volatile boolean isDestroyed
-
-
Constructor Details
-
AbstractThreadPoolStrategy
AbstractThreadPoolStrategy(ConsoleLogger logger, ExecutorService threadPool) -
AbstractThreadPoolStrategy
AbstractThreadPoolStrategy(ConsoleLogger logger, ExecutorService threadPool, Collection<Future<?>> futureResults)
-
-
Method Details
-
getThreadPool
-
getFutureResults
-
schedule
Description copied from class:SchedulingStrategy
Schedules tasks ifSchedulingStrategy.canSchedule()
.- Specified by:
schedule
in classSchedulingStrategy
- Parameters:
task
- runnable to schedule in a thread pool or invoke- See Also:
-
RunnerScheduler.schedule(Runnable)
Executor.execute(Runnable)
-
stop
protected boolean stop()Description copied from class:SchedulingStrategy
Stops scheduling new tasks (e.g. byExecutorService.shutdown()
on a private thread pool which cannot be shared with other strategy).- Specified by:
stop
in classSchedulingStrategy
- Returns:
true
if successfully stopped the scheduler, elsefalse
if already stopped (a shared thread pool was shutdown externally).- See Also:
-
stopNow
protected boolean stopNow()Description copied from class:SchedulingStrategy
Stops scheduling new tasks andinterrupts
running tasks (e.g. byExecutorService.shutdownNow()
on a private thread pool which cannot be shared with other strategy).
This method callsSchedulingStrategy.stop()
by default.- Overrides:
stopNow
in classSchedulingStrategy
- Returns:
true
if successfully stopped the scheduler, elsefalse
if already stopped (a shared thread pool was shutdown externally).- See Also:
-
setDefaultShutdownHandler
- Overrides:
setDefaultShutdownHandler
in classSchedulingStrategy
- See Also:
-
destroy
public boolean destroy()Description copied from interface:Destroyable
CallingThreadPoolExecutor.shutdown()
andThreadPoolExecutor.awaitTermination(long, java.util.concurrent.TimeUnit)
.- Returns:
true
if not interrupted in current thread
-