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 class AbstractThreadPoolStrategy extends SchedulingStrategy
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:
SchedulingStrategy,SharedThreadPoolStrategy,NonSharedThreadPoolStrategy
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Collection<java.util.concurrent.Future<?>>futureResultsprivate booleanisDestroyedprivate java.util.concurrent.ExecutorServicethreadPool
-
Constructor Summary
Constructors Constructor Description AbstractThreadPoolStrategy(ConsoleStream logger, java.util.concurrent.ExecutorService threadPool)AbstractThreadPoolStrategy(ConsoleStream logger, java.util.concurrent.ExecutorService threadPool, java.util.Collection<java.util.concurrent.Future<?>> futureResults)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleandestroy()CallingThreadPoolExecutor.shutdown()andThreadPoolExecutor.awaitTermination(long, java.util.concurrent.TimeUnit).protected java.util.Collection<java.util.concurrent.Future<?>>getFutureResults()protected java.util.concurrent.ExecutorServicegetThreadPool()voidschedule(java.lang.Runnable task)Schedules tasks ifSchedulingStrategy.canSchedule().protected voidsetDefaultShutdownHandler(Scheduler.ShutdownHandler handler)protected booleanstop()Stops scheduling new tasks (e.g.protected booleanstopNow()Stops scheduling new tasks andinterruptsrunning tasks (e.g.-
Methods inherited from class org.apache.maven.surefire.junitcore.pc.SchedulingStrategy
canSchedule, disable, finished, hasSharedThreadPool, logQuietly
-
-
-
-
Constructor Detail
-
AbstractThreadPoolStrategy
AbstractThreadPoolStrategy(ConsoleStream logger, java.util.concurrent.ExecutorService threadPool)
-
AbstractThreadPoolStrategy
AbstractThreadPoolStrategy(ConsoleStream logger, java.util.concurrent.ExecutorService threadPool, java.util.Collection<java.util.concurrent.Future<?>> futureResults)
-
-
Method Detail
-
getThreadPool
protected final java.util.concurrent.ExecutorService getThreadPool()
-
getFutureResults
protected final java.util.Collection<java.util.concurrent.Future<?>> getFutureResults()
-
schedule
public void schedule(java.lang.Runnable task)
Description copied from class:SchedulingStrategySchedules tasks ifSchedulingStrategy.canSchedule().- Specified by:
schedulein 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:SchedulingStrategyStops scheduling new tasks (e.g. byExecutorService.shutdown()on a private thread pool which cannot be shared with other strategy).- Specified by:
stopin classSchedulingStrategy- Returns:
trueif successfully stopped the scheduler, elsefalseif already stopped (a shared thread pool was shutdown externally).- See Also:
ExecutorService.shutdown()
-
stopNow
protected boolean stopNow()
Description copied from class:SchedulingStrategyStops scheduling new tasks andinterruptsrunning tasks (e.g. byExecutorService.shutdownNow()on a private thread pool which cannot be shared with other strategy).
This method callsSchedulingStrategy.stop()by default.- Overrides:
stopNowin classSchedulingStrategy- Returns:
trueif successfully stopped the scheduler, elsefalseif already stopped (a shared thread pool was shutdown externally).- See Also:
ExecutorService.shutdownNow()
-
setDefaultShutdownHandler
protected void setDefaultShutdownHandler(Scheduler.ShutdownHandler handler)
- Overrides:
setDefaultShutdownHandlerin classSchedulingStrategy- See Also:
Scheduler.ShutdownHandler
-
destroy
public boolean destroy()
Description copied from interface:DestroyableCallingThreadPoolExecutor.shutdown()andThreadPoolExecutor.awaitTermination(long, java.util.concurrent.TimeUnit).- Returns:
trueif not interrupted in current thread
-
-