public class LegacyScheduler extends Object implements Runnable, PausableFiber, Scheduler
PAUSE_PENDING, PAUSED, RESUME_PENDING
RUNNING, START_PENDING, STARTING, STATUS_NAMES, STOP_PENDING, STOPPED
Constructor and Description |
---|
LegacyScheduler(String parent,
int maxSize)
Constructs a new instance of the scheduler.
|
LegacyScheduler(String parent,
int maxSize,
float lowMark,
float hiMark)
Constructs a new instance of the scheduler.
|
Modifier and Type | Method and Description |
---|---|
long |
getCurrentTime()
getCurrentTime
|
String |
getName()
Returns the name of this fiber.
|
long |
getNumTasksExecuted()
Returns the total number of scheduled tasks (ReadyRunnables) that have
been executed since the scheduler was initialized.
|
ExecutorService |
getRunner()
Returns the pool of threads that are used to executed the runnable
instances scheduled by the class' instance.
|
int |
getScheduled()
Returns total number of elements currently scheduled.
|
int |
getStatus()
getStatus
|
void |
pause()
pause
|
void |
resume()
resume
|
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()
start
|
void |
stop()
stop
|
public LegacyScheduler(String parent, int maxSize)
parent
- String prepended to "Scheduler" to create fiber namemaxSize
- The maximum size of the thread pool.public LegacyScheduler(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 Scheduler
schedule
in interface ScheduleTimer
interval
- a long.runnable
- a ReadyRunnable
object.public long getCurrentTime()
getCurrentTime
getCurrentTime
in interface Scheduler
getCurrentTime
in interface Timer
public void start()
start
public void stop()
stop
public void pause()
pause
pause
in interface PausableFiber
pause
in interface Scheduler
public void resume()
resume
resume
in interface PausableFiber
resume
in interface Scheduler
public int getStatus()
getStatus
public String getName()
public int getScheduled()
public ExecutorService getRunner()
public void run()
public long getNumTasksExecuted()
getNumTasksExecuted
in interface Scheduler
Copyright © 2021. All rights reserved.