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 nanoseconds.final RunnableThe function to execute when the callback fires.final longThe unique id for this callback to allow callbacks to be tracked and removed from the queue throughout robot operation.final longThe period at which to run the callback in nanoseconds. -
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 their stable identity.inthashCode()Returns a hash code based on the stable identity.
-
Field Details
-
func
The function to execute when the callback fires. -
period
public final long periodThe period at which to run the callback in nanoseconds. -
expirationTime
public long expirationTimeThe next scheduled execution time in monotonic timestamp nanoseconds. -
id
public final long idThe unique id for this callback to allow callbacks to be tracked and removed from the queue throughout robot operation.
-
-
Constructor Details
-
Callback
Construct a callback container.- Parameters:
func- The callback to run.startTime- The common starting point for all callback scheduling in nanoseconds.period- The period at which to run the callback in nanoseconds.offset- The offset from the common starting time in nanoseconds.
-
Callback
Construct a callback container.- Parameters:
func- The callback to run.timestamp- The common starting point for all callback scheduling in nanoseconds.periodSeconds- The period at which to run the callback in seconds.offsetSeconds- The offset from the common starting time in seconds.
-
Callback
Construct a callback container.- Parameters:
func- The callback to run.timestamp- The common starting point for all callback scheduling in nanoseconds.periodSeconds- The period at which to run the callback in seconds.
-
-
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.
-