Package kilim
Class Scheduler
java.lang.Object
kilim.Scheduler
- Direct Known Subclasses:
AffineScheduler,ForkJoinScheduler
This is a basic FIFO Executor. It maintains a list of runnable tasks and hands them out to WorkerThreads. Note
that we don't maintain a list of all tasks, but we will at some point when we introduce monitoring/watchdog
services. Paused tasks are not GC'd because their PauseReasons ought to be registered with some other live
object.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classstatic interface -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic Scheduler.Loggerstatic intstatic Schedulerprivate Scheduler.Loggerstatic Schedulerprotected AtomicBooleanprivate static final ThreadLocal<Task> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static Taskstatic Schedulerget and possibly instantiate a scheduler that is pinnablestatic Schedulerget and possibly instantiate a default schedulerprotected Schedulerabstract voididledown()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 executedabstract booleanare 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 emptybooleanbooleanprotected voidwrite to the logprotected static voida static accessor to allow log to be protectedstatic Schedulermake(int numThreads) return a new default Scheduler with default queue lengthabstract intabstract voidschedule a task to runvoidSchedule a task to run.abstract voidprotected static voidstatic voidstatic voidvoidsetLogger(Scheduler.Logger logger) set a loggervoidshutdown()
-
Field Details
-
defaultScheduler
-
pinnableScheduler
-
defaultNumberThreads
public static int defaultNumberThreads -
taskMgr_
-
defaultLogger
-
shutdown
-
logger
-
-
Constructor Details
-
Scheduler
public Scheduler()
-
-
Method Details
-
getCurrentTask
-
setCurrentTask
-
make
return a new default Scheduler with default queue length- Parameters:
numThreads- the number of threads to use, or use the default if less than one- Returns:
- the new Scheduler
-
isEmptyish
public 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 -
numThreads
public abstract int numThreads() -
isPinnable
public boolean isPinnable() -
schedule
Schedule a task to run. It is the task's job to ensure that it is not scheduled when it is runnable. the default index for assignment to an executor -
schedule
schedule a task to run- Parameters:
index- the index of the executor to use, or less than zero to use the default (round robin) assignmentt- the task
-
scheduleTimer
-
idledown
public 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 -
shutdown
public void shutdown() -
isShutdown
public boolean isShutdown() -
logRelay
a static accessor to allow log to be protected -
log
write to the log- Parameters:
src- the source of the log objectobj- the object to log
-
setLogger
set a logger- Parameters:
logger- the logger
-
getDefaultScheduler
get and possibly instantiate a default scheduler -
getDefaultPinnable
get and possibly instantiate a scheduler that is pinnable -
getPinnable
-
setDefaultScheduler
-
setDefaultPinnable
-