Class PeriodicPriorityQueue.Callback
java.lang.Object
org.wpilib.internal.PeriodicPriorityQueue.Callback
- All Implemented Interfaces:
Comparable<PeriodicPriorityQueue.Callback>
- Enclosing class:
PeriodicPriorityQueue
public static class PeriodicPriorityQueue.Callback
extends Object
implements Comparable<PeriodicPriorityQueue.Callback>
A periodic callback with scheduling metadata.
Each callback tracks its target function, period, and next expiration time. After execution, the expiration time is automatically advanced by full periods to maintain precise timing even when execution is delayed.
-
Field Summary
FieldsModifier and TypeFieldDescriptionlongThe next scheduled execution time in monotonic timestamp microseconds.final RunnableThe function to execute when the callback fires.final longThe period at which to run the callback in microseconds. -
Constructor Summary
ConstructorsConstructorDescriptionConstruct a callback container.Construct a callback container.Construct a callback container. -
Method Summary
Modifier and TypeMethodDescriptionintCompares this callback to another based on expiration time.booleanCompares callbacks based on expiration time for equality.inthashCode()Returns a hash code based on the expiration time.
-
Field Details
-
func
-
period
The period at which to run the callback in microseconds. -
expirationTime
The next scheduled execution time in monotonic timestamp microseconds.
-
-
Constructor Details
-
Callback
Construct a callback container.- Parameters:
func- The callback to run.startTime- The common starting point for all callback scheduling in microseconds.period- The period at which to run the callback in microseconds.offset- The offset from the common starting time in microseconds.
-
Callback
Construct a callback container.- Parameters:
func- The callback to run.timestamp- The common starting point for all callback scheduling in microseconds.periodSeconds- The period at which to run the callback in seconds.offsetSeconds- The offset from the common starting time in seconds.
-
Callback
-
-
Method Details
-
equals
-
hashCode
-
compareTo
Compares this callback to another based on expiration time.Callbacks with earlier expiration times are considered "less than" those with later expiration times. This ordering is used by the priority queue to determine execution order.
- Specified by:
compareToin interfaceComparable<PeriodicPriorityQueue.Callback>- Parameters:
rhs- The callback to compare to.- Returns:
- negative if this expires before rhs, positive if after, zero if equal.
-