public abstract class Scheduler
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
Scheduler.Logger |
| Modifier and Type | Field and Description |
|---|---|
static Scheduler.Logger |
defaultLogger |
static int |
defaultNumberThreads |
static Scheduler |
defaultScheduler |
static Scheduler |
pinnableScheduler |
protected java.util.concurrent.atomic.AtomicBoolean |
shutdown |
| Constructor and Description |
|---|
Scheduler() |
| Modifier and Type | Method and Description |
|---|---|
protected static Task |
getCurrentTask() |
static Scheduler |
getDefaultPinnable()
get and possibly instantiate a scheduler that is pinnable
|
static Scheduler |
getDefaultScheduler()
get and possibly instantiate a default scheduler
|
protected Scheduler |
getPinnable() |
abstract void |
idledown()
block the thread till a moment at which all scheduled tasks have completed and then shutdown the scheduler
does not prevent scheduling new tasks (from other threads) until the shutdown is complete so such a task
could be partially executed
|
abstract boolean |
isEmptyish()
are the queues empty allows false positives, but not false negatives ie, if this method returns false, then
at some moment during the call at least one queue was non-empty if it returns true then for each queue there
was a moment during the call when it was empty
|
boolean |
isPinnable() |
boolean |
isShutdown() |
protected void |
log(java.lang.Object src,
java.lang.Object obj)
write to the log
|
protected static void |
logRelay(Scheduler sched,
java.lang.Object src,
java.lang.Object obj)
a static accessor to allow log to be protected
|
static Scheduler |
make(int numThreads)
return a new default Scheduler with default queue length
|
abstract int |
numThreads() |
abstract void |
schedule(int index,
Task t)
schedule a task to run
|
void |
schedule(Task t)
Schedule a task to run.
|
abstract void |
scheduleTimer(Timer t) |
protected static void |
setCurrentTask(Task t) |
static void |
setDefaultPinnable(Scheduler s) |
static void |
setDefaultScheduler(Scheduler s) |
void |
setLogger(Scheduler.Logger logger)
set a logger
|
void |
shutdown() |
public static volatile Scheduler defaultScheduler
public static volatile Scheduler pinnableScheduler
public static int defaultNumberThreads
public static Scheduler.Logger defaultLogger
protected java.util.concurrent.atomic.AtomicBoolean shutdown
protected static Task getCurrentTask()
protected static void setCurrentTask(Task t)
public static Scheduler make(int numThreads)
numThreads - the number of threads to use, or use the default if less than onepublic abstract boolean isEmptyish()
public abstract int numThreads()
public boolean isPinnable()
public void schedule(Task t)
public abstract void schedule(int index,
Task t)
index - the index of the executor to use, or less than zero to use the default (round robin) assignmentt - the taskpublic abstract void scheduleTimer(Timer t)
public abstract void idledown()
public void shutdown()
public boolean isShutdown()
protected static void logRelay(Scheduler sched, java.lang.Object src, java.lang.Object obj)
protected void log(java.lang.Object src,
java.lang.Object obj)
src - the source of the log objectobj - the object to logpublic void setLogger(Scheduler.Logger logger)
logger - the loggerpublic static Scheduler getDefaultScheduler()
public static Scheduler getDefaultPinnable()
protected Scheduler getPinnable()
public static void setDefaultScheduler(Scheduler s)
public static void setDefaultPinnable(Scheduler s)