APIdia Launch Partner
Top Description Fields Methods
jdk.internal.net.http.quic

pack-priv sealed Interface QuicTimedEvent

permits PacketTransmissionTask, Marker, ClosedConnection, TimedEvent, MaxInitialTimer
Known Direct Implementers
jdk.internal.net.http.quic.QuicTimerQueue.Marker, jdk.internal.net.http.quic.IdleTimeoutManager.TimedEvent, jdk.internal.net.http.quic.PacketSpaceManager.PacketTransmissionTask, jdk.internal.net.http.quic.QuicConnectionImpl.MaxInitialTimer, jdk.internal.net.http.quic.QuicEndpoint.ClosedConnection
Imports
java.util.Comparator, jdk.internal.net.http.common.Deadline

Models an event which is triggered upon reaching a deadline. QuicTimedEvent instances are designed to be registered with a single QuicTimerQueue.

Implementation Specification

Implementations should make sure that each instance of QuicTimedEvent is only present once in a single QuicTimerQueue at any given time. It is however allowed to register the event again with the same QuicTimerQueue after it has been handled, or if it is no longer registered in any queue.

Field Summary

Modifier and TypeField and Description
public static final Comparator<QuicTimedEvent>
COMPARATOR

A comparator that compares QuicTimedEvent instances by their deadline, in the same manner as QuicTimedEvent::compare.

Method Summary

Modifier and TypeMethod and Description
public static int

Returns:

whether the first element is less, same, or greater than the second.
compare
(QuicTimedEvent
a first QuicTimedEvent instance
one
,
QuicTimedEvent
a second QuicTimedEvent instance
two
)

Compares two instance of QuicTimedEvent.

public default int

Returns:

-1, 0, or 1 depending on whether this event's deadline is before, equals to, or after, the other event's deadline.
compareDeadlines
(QuicTimedEvent
the other event
other
)

Compares this event's deadline with the other event's deadline.

public Deadline

Returns:

the deadline at which the event should be triggered, or Deadline#MAX if the event does not need to be scheduled
deadline
()

Returns the deadline at which the event should be triggered, or Deadline#MAX if the event does not need to be scheduled.

public long

Returns:

this event's id.
eventId
()

An event id, obtained at construction time from QuicTimerQueue#newEventId().

public Deadline

Returns:

a new deadline if the event should be rescheduled right away, Deadline.MAX otherwise.
handle
()

Handles the triggered event.

public default boolean

Returns:

true if this event's deadline is before the other's event deadline
isBefore
(QuicTimedEvent
the other event
other
)

Returns true if this event's deadline is before the other's event deadline.

public Deadline
refreshDeadline()

Called to cause an event to refresh its deadline.

Field Detail

COMPARATORback to summary
public static final Comparator<QuicTimedEvent> COMPARATOR

A comparator that compares QuicTimedEvent instances by their deadline, in the same manner as QuicTimedEvent::compare.

Method Detail

compareback to summary
public static int compare(QuicTimedEvent one, QuicTimedEvent two)

Compares two instance of QuicTimedEvent. First compared their deadline(), then their eventId(). It is expected that two elements with same deadline and same event id must the same QuicTimedEvent instance.

Parameters
one:QuicTimedEvent

a first QuicTimedEvent instance

two:QuicTimedEvent

a second QuicTimedEvent instance

Returns:int

whether the first element is less, same, or greater than the second.

compareDeadlinesback to summary
public default int compareDeadlines(QuicTimedEvent other)

Compares this event's deadline with the other event's deadline.

Implementation Specification

The default implementation of this method compares deadlines in the same manner as this.deadline().compareTo(other.deadline()) would.

Parameters
other:QuicTimedEvent

the other event

Returns:int

-1, 0, or 1 depending on whether this event's deadline is before, equals to, or after, the other event's deadline.

deadlineback to summary
public Deadline deadline()

Returns the deadline at which the event should be triggered, or Deadline#MAX if the event does not need to be scheduled.

Implementation Specification

Care should be taken to not change the deadline while the event is registered with a timer queue. The only safe time when the deadline can be changed is:

  • when refreshDeadline() method, since the event is not in any queue at that point,
  • when the deadline is Deadline#MAX, since the event should not be in any queue if it has no deadline
Returns:Deadline

the deadline at which the event should be triggered, or Deadline#MAX if the event does not need to be scheduled

eventIdback to summary
public long eventId()

An event id, obtained at construction time from QuicTimerQueue#newEventId(). This is used to implement a total order among subclasses.

Returns:long

this event's id.

handleback to summary
public Deadline handle()

Handles the triggered event. Returns a new deadline, if the event needs to be rescheduled, or Deadline.MAX otherwise.

Implementation Specification

The deadline should not be changed before refreshDeadline() is called.

Returns:Deadline

a new deadline if the event should be rescheduled right away, Deadline.MAX otherwise.

isBeforeback to summary
public default boolean isBefore(QuicTimedEvent other)

Returns true if this event's deadline is before the other's event deadline.

Implementation Specification

The default implementation of this method is to return deadline().isBefore(other.deadline()).

Parameters
other:QuicTimedEvent

the other event

Returns:boolean

true if this event's deadline is before the other's event deadline

refreshDeadlineback to summary
public Deadline refreshDeadline()

Called to cause an event to refresh its deadline. This method is called by the QuicTimerQueue when rescheduling an event.

API Note

The value returned by deadline() can only be safely updated when this method is called.