public abstract class SchedulingStrategy extends Object implements Destroyable
Scheduler
.
schedule(Runnable)
and awaiting them
completed in finished()
. Both methods should be used in one thread.Modifier | Constructor and Description |
---|---|
protected |
SchedulingStrategy(ConsoleStream 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(Throwable t) |
protected abstract void |
schedule(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, wait
destroy
protected SchedulingStrategy(ConsoleStream logger)
protected abstract void schedule(Runnable task)
canSchedule()
.task
- runnable to schedule in a thread pool or invokeRejectedExecutionException
- if task
cannot be scheduled for executionNullPointerException
- if task is nullRunnerScheduler.schedule(Runnable)
,
Executor.execute(Runnable)
protected abstract boolean finished() throws InterruptedException
true
if successfully stopped the scheduler, else
false
if already stopped (a shared thread
pool was shutdown externally).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).true
if successfully stopped the scheduler, else
false
if already stopped (a shared thread
pool was shutdown externally).ExecutorService.shutdown()
protected boolean stopNow()
interrupts
running tasks
(e.g. by ExecutorService.shutdownNow()
on a private thread pool
which cannot be shared with other strategy).
stop()
by default.true
if successfully stopped the scheduler, else
false
if already stopped (a shared thread
pool was shutdown externally).ExecutorService.shutdownNow()
protected boolean disable()
Balancer
to acquire a new permit.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()
true
if a thread pool associated with this strategy
can be shared with other strategies.protected boolean canSchedule()
true
unless stopped, finished or disabled.protected void logQuietly(Throwable t)
Copyright © 2004–2018 The Apache Software Foundation. All rights reserved.