Class SchedulingStrategy
java.lang.Object
org.apache.maven.surefire.junitcore.pc.SchedulingStrategy
- All Implemented Interfaces:
Destroyable
Specifies the strategy of scheduling whether sequential, or parallel.
The strategy may use a thread pool shared with other strategies.
One instance of strategy can be used just by one
The strategy is scheduling tasks in
One instance of strategy can be used just by one
Scheduler
.
The strategy is scheduling tasks in
schedule(Runnable)
and awaiting them
completed in finished()
. Both methods should be used in one thread.- Since:
- 2.16
- Author:
- Tibor Digana (tibor17)
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
SchedulingStrategy
(org.apache.maven.plugin.surefire.log.api.ConsoleLogger logger) -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
protected boolean
disable()
Persistently disables this strategy.protected abstract boolean
finished()
Waiting for scheduled tasks to finish.protected abstract boolean
protected void
protected abstract void
Schedules tasks ifcanSchedule()
.protected void
protected abstract boolean
stop()
Stops scheduling new tasks (e.g.protected boolean
stopNow()
Stops scheduling new tasks andinterrupts
running tasks (e.g.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.maven.surefire.junitcore.pc.Destroyable
destroy
-
Constructor Details
-
SchedulingStrategy
protected SchedulingStrategy(org.apache.maven.plugin.surefire.log.api.ConsoleLogger logger)
-
-
Method Details
-
schedule
Schedules tasks ifcanSchedule()
.- Parameters:
task
- runnable to schedule in a thread pool or invoke- Throws:
RejectedExecutionException
- iftask
cannot be scheduled for executionNullPointerException
- iftask
isnull
- See Also:
-
RunnerScheduler.schedule(Runnable)
Executor.execute(Runnable)
-
finished
Waiting for scheduled tasks to finish. New tasks will not be scheduled by calling this method.- Returns:
true
if successfully stopped the scheduler, elsefalse
if already stopped (a shared thread pool was shutdown externally).- Throws:
InterruptedException
- if interrupted while waiting for scheduled tasks to finish- See Also:
-
RunnerScheduler.finished()
-
stop
protected abstract boolean stop()Stops scheduling new tasks (e.g. byExecutorService.shutdown()
on a private thread pool which cannot be shared with other strategy).- Returns:
true
if successfully stopped the scheduler, elsefalse
if already stopped (a shared thread pool was shutdown externally).- See Also:
-
stopNow
protected boolean stopNow()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 callsstop()
by default.- Returns:
true
if successfully stopped the scheduler, elsefalse
if already stopped (a shared thread pool was shutdown externally).- See Also:
-
disable
protected boolean disable()Persistently disables this strategy. Atomically ignoresBalancer
to acquire a new permit.
The methodcanSchedule()
atomically returnsfalse
.- Returns:
true
ifcanSchedule()
has returntrue
on the beginning of this method call.
-
setDefaultShutdownHandler
-
canSchedule
protected boolean canSchedule()- Returns:
true
unless stopped, finished or disabled.
-
logQuietly
-