public class Scheduler extends Object implements Runnable, PausableFiber, ScheduleTimer
| Modifier and Type | Field and Description |
|---|---|
Map<Long,BlockingQueue<ReadyRunnable>> |
m_queues
The map of queue that contain
ready runnable
instances. |
PAUSE_PENDING, PAUSED, RESUME_PENDINGRUNNING, START_PENDING, STARTING, STATUS_NAMES, STOP_PENDING, STOPPED| Constructor and Description |
|---|
Scheduler(String parent,
int maxSize)
Constructs a new instance of the scheduler.
|
Scheduler(String parent,
int maxSize,
float lowMark,
float hiMark)
Constructs a new instance of the scheduler.
|
| Modifier and Type | Method and Description |
|---|---|
long |
getCurrentTime()
This returns the current time for the scheduler
|
String |
getName()
Returns the name of this fiber.
|
long |
getNumTasksExecuted() |
ReadyRunnable |
getReadyRunnable(ReadyRunnable runnable)
This method is used to get a ready runnable in the system.
|
ReadyRunnable |
getReadyRunnable(ReadyRunnable runnable,
long interval)
getReadyRunnable
|
int |
getStatus()
Returns the current of this fiber.
|
void |
pause()
Pauses the scheduler if it is current running.
|
void |
resume()
Resumes the scheduler if it has been paused.
|
void |
run()
The main method of the scheduler.
|
void |
schedule(long interval,
ReadyRunnable runnable)
schedule
|
void |
schedule(ReadyRunnable runnable,
long interval)
This method is used to schedule a ready runnable in the system.
|
void |
start()
Starts the fiber.
|
void |
stop()
Stops the fiber.
|
void |
unschedule(ReadyRunnable runnable)
This method is used to unschedule a ready runnable in the system.
|
void |
unschedule(ReadyRunnable runnable,
long interval)
This method is used to unschedule a ready runnable in the system.
|
public Map<Long,BlockingQueue<ReadyRunnable>> m_queues
ready runnable
instances. The queues are mapped according to the interval of scheduling.public Scheduler(String parent, int maxSize)
parent - String prepended to "Scheduler" to create fiber namemaxSize - The maximum size of the thread pool.public Scheduler(String parent, int maxSize, float lowMark, float hiMark)
parent - String prepended to "Scheduler" to create fiber namemaxSize - The maximum size of the thread pool.lowMark - The low water mark ratios of thread size to threads when
threads are stopped.hiMark - The high water mark ratio of thread size to threads when
threads are started.public void schedule(ReadyRunnable runnable, long interval)
runnable - The element to run when interval expires.interval - The queue to add the runnable to.RuntimeException - Thrown if an error occurs adding the element to the queue.public void schedule(long interval,
ReadyRunnable runnable)
schedule
This method is used to schedule a ready runnable in the system. The interval is used as the key for determining which queue to add the runnable.schedule in interface ScheduleTimerinterval - a long.runnable - a ReadyRunnable object.public void unschedule(ReadyRunnable runnable)
runnable - The element to remove from queue intervals.public void unschedule(ReadyRunnable runnable, long interval)
interval - The queue to add the runnable to.runnable - The element to remove.public ReadyRunnable getReadyRunnable(ReadyRunnable runnable)
runnable - The element to get from queues interval.ReadyRunnable object.public ReadyRunnable getReadyRunnable(ReadyRunnable runnable, long interval)
getReadyRunnable
runnable - a ReadyRunnable object.interval - a long.ReadyRunnable object.public long getCurrentTime()
getCurrentTime in interface Timerpublic void start()
start in interface FiberIllegalStateException - Thrown if the fiber is already running.public void stop()
stop in interface FiberIllegalStateException - Throws if the fiber has never been started.public void pause()
pause in interface PausableFiberIllegalStateException - Throws if the operation could not be completed due to the
fiber's state.public void resume()
resume in interface PausableFiberIllegalStateException - Throws if the operation could not be completed due to the
fiber's state.public int getStatus()
public String getName()
public void run()
public long getNumTasksExecuted()
Copyright © 2020. All rights reserved.