public class PriorityScheduler extends SchedulerBase<com.badlogic.gdx.ai.sched.PriorityScheduler.PrioritySchedulableRecord>
PriorityScheduler works like a LoadBalancingScheduler but allows different tasks to get a different share of
the available time by assigning a priority to each task. The higher the priority the longer the amount of the available time
dedicated to the corresponding task.SchedulerBase.SchedulableRecord| Modifier and Type | Field and Description |
|---|---|
protected int |
frame
The current frame number
|
dryRunFrames, phaseCounters, runList, schedulableRecords| Constructor and Description |
|---|
PriorityScheduler(int dryRunFrames)
Creates a
PriorityScheduler. |
| Modifier and Type | Method and Description |
|---|---|
void |
add(Schedulable schedulable,
int frequency,
int phase)
Adds the
schedulable to the list using the given frequency and phase with priority 1. |
void |
add(Schedulable schedulable,
int frequency,
int phase,
float priority)
Adds the
schedulable to the list using the given frequency, phase and priority. |
void |
addWithAutomaticPhasing(Schedulable schedulable,
int frequency)
Adds the
schedulable to the list using the given frequency, priority 1 and a phase calculated by a dry run
of the scheduler. |
void |
addWithAutomaticPhasing(Schedulable schedulable,
int frequency,
float priority)
Adds the
schedulable to the list using the given frequency and priority while the phase is
calculated by a dry run of the scheduler. |
void |
run(long timeToRun)
Executes scheduled tasks based on their frequency and phase.
|
calculatePhasepublic PriorityScheduler(int dryRunFrames)
PriorityScheduler.dryRunFrames - number of frames simulated by the dry run to calculate the phase when adding a schedulable via
addWithAutomaticPhasing(Schedulable, int) and addWithAutomaticPhasing(Schedulable, int, float)public void run(long timeToRun)
timeToRun - the maximum time in nanoseconds this scheduler should run on the current frame.public void addWithAutomaticPhasing(Schedulable schedulable, int frequency)
schedulable to the list using the given frequency, priority 1 and a phase calculated by a dry run
of the scheduler.schedulable - the task to schedulefrequency - the frequencypublic void addWithAutomaticPhasing(Schedulable schedulable, int frequency, float priority)
schedulable to the list using the given frequency and priority while the phase is
calculated by a dry run of the scheduler.schedulable - the task to schedulefrequency - the frequencypriority - the prioritypublic void add(Schedulable schedulable, int frequency, int phase)
schedulable to the list using the given frequency and phase with priority 1.schedulable - the task to schedulefrequency - the frequencyphase - the phasepublic void add(Schedulable schedulable, int frequency, int phase, float priority)
schedulable to the list using the given frequency, phase and priority.schedulable - the task to schedulefrequency - the frequencyphase - the phasepriority - the priority