public abstract class SchedulingStrategy extends java.lang.Object implements Destroyable
Scheduler.
The strategy is scheduling tasks in schedule(Runnable) and awaiting them
completed in finished(). Both methods should be used in one thread.| Modifier and Type | Field and Description |
|---|---|
private java.util.concurrent.atomic.AtomicBoolean |
canSchedule |
private ConsoleLogger |
logger |
| Modifier | Constructor and Description |
|---|---|
protected |
SchedulingStrategy(ConsoleLogger logger) |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
canSchedule() |
protected boolean |
disable()
Persistently disables this strategy.
|
protected abstract boolean |
finished()
Waiting for scheduled tasks to finish.
|
protected abstract boolean |
hasSharedThreadPool() |
protected void |
logQuietly(java.lang.Throwable t) |
protected abstract void |
schedule(java.lang.Runnable task)
Schedules tasks if
canSchedule(). |
protected void |
setDefaultShutdownHandler(Scheduler.ShutdownHandler handler) |
protected abstract boolean |
stop()
Stops scheduling new tasks (e.g.
|
protected boolean |
stopNow()
Stops scheduling new tasks and interrupts running tasks
(e.g.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdestroyprivate final java.util.concurrent.atomic.AtomicBoolean canSchedule
private final ConsoleLogger logger
protected SchedulingStrategy(ConsoleLogger logger)
protected abstract void schedule(java.lang.Runnable task)
canSchedule().task - runnable to schedule in a thread pool or invokejava.util.concurrent.RejectedExecutionException - if task
cannot be scheduled for executionjava.lang.NullPointerException - if task is nullRunnerScheduler.schedule(Runnable),
Executor.execute(Runnable)protected abstract boolean finished()
throws java.lang.InterruptedException
java.lang.InterruptedException - if interrupted while waiting
for scheduled tasks to finishRunnerScheduler.finished()protected abstract boolean stop()
ExecutorService.shutdown()
on a private thread pool which cannot be shared with other strategy).ExecutorService.shutdown()protected boolean stopNow()
ExecutorService.shutdownNow() on a private thread pool
which cannot be shared with other strategy).
This method calls stop() by default.ExecutorService.shutdownNow()protected boolean disable()
Balancer to acquire a new permit.
The method canSchedule() atomically returns false.true if canSchedule() has return true on the beginning of this method call.protected void setDefaultShutdownHandler(Scheduler.ShutdownHandler handler)
protected abstract boolean hasSharedThreadPool()
protected boolean canSchedule()
protected void logQuietly(java.lang.Throwable t)