Package kilim
Class ForkJoinScheduler
- java.lang.Object
-
- kilim.Scheduler
-
- kilim.ForkJoinScheduler
-
- All Implemented Interfaces:
TimerService.WatchdogContext
public class ForkJoinScheduler extends Scheduler implements TimerService.WatchdogContext
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) classForkJoinScheduler.ForkedRunnable<V>-
Nested classes/interfaces inherited from class kilim.Scheduler
Scheduler.BasicLogger, Scheduler.Logger
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.atomic.AtomicIntegercount(package private) java.util.concurrent.ForkJoinPoolpoolprivate TimerServicetimerService-
Fields inherited from class kilim.Scheduler
defaultLogger, defaultNumberThreads, defaultScheduler, pinnableScheduler, shutdown
-
-
Constructor Summary
Constructors Constructor Description ForkJoinScheduler(int numThreads)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 executedbooleanisEmpty()booleanisEmptyish()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 emptybooleanisPinnable()static voidmain(java.lang.String[] args)run the main method from another class using this scheduler as the default schedulerintnumThreads()private static java.lang.IntegerparseNum(java.lang.String[] args, int index)private static java.lang.String[]processArgs(java.lang.String[] args, int offset)voidpublish(java.lang.Runnable task)voidpublish(TimerService.WatchdogTask dog)private static voidrun(java.lang.String className, java.lang.String method, java.lang.String... args)voidschedule(int index, Task task)schedule a task to runvoidscheduleTimer(Timer t)voidshutdown()booleanwaitIdle(int delay)-
Methods inherited from class kilim.Scheduler
getCurrentTask, getDefaultPinnable, getDefaultScheduler, getPinnable, isShutdown, log, logRelay, make, schedule, setCurrentTask, setDefaultPinnable, setDefaultScheduler, setLogger
-
-
-
-
Field Detail
-
pool
java.util.concurrent.ForkJoinPool pool
-
timerService
private TimerService timerService
-
count
private java.util.concurrent.atomic.AtomicInteger count
-
-
Method Detail
-
publish
public void publish(TimerService.WatchdogTask dog)
- Specified by:
publishin interfaceTimerService.WatchdogContext
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfaceTimerService.WatchdogContext
-
isPinnable
public boolean isPinnable()
- Overrides:
isPinnablein classScheduler
-
schedule
public void schedule(int index, Task task)Description copied from class:Schedulerschedule a task to run
-
publish
public void publish(java.lang.Runnable task)
-
isEmptyish
public boolean isEmptyish()
Description copied from class:Schedulerare 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- Specified by:
isEmptyishin interfaceTimerService.WatchdogContext- Specified by:
isEmptyishin classScheduler
-
numThreads
public int numThreads()
- Specified by:
numThreadsin classScheduler
-
scheduleTimer
public void scheduleTimer(Timer t)
- Specified by:
scheduleTimerin classScheduler
-
idledown
public void idledown()
Description copied from class:Schedulerblock 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
-
waitIdle
public boolean waitIdle(int delay)
-
processArgs
private static java.lang.String[] processArgs(java.lang.String[] args, int offset)
-
parseNum
private static java.lang.Integer parseNum(java.lang.String[] args, int index)
-
run
private static void run(java.lang.String className, java.lang.String method, java.lang.String... args) throws java.lang.Exception- Throws:
java.lang.Exception
-
main
public static void main(java.lang.String[] args) throws java.lang.Exceptionrun the main method from another class using this scheduler as the default scheduler- Throws:
java.lang.Exception
-
-