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

public abstract sealed Class QuicSelector<T extends QuicEndpoint>

extends Object
implements Runnable, AutoCloseable
permits QuicNioSelector, QuicVirtualThreadPoller
Class Inheritance
All Implemented Interfaces
java.lang.AutoCloseable, java.lang.Runnable
Known Direct Subclasses
jdk.internal.net.http.quic.QuicSelector.QuicVirtualThreadPoller, jdk.internal.net.http.quic.QuicSelector.QuicNioSelector
Imports
java.io.IOException, java.nio.channels.CancelledKeyException, .ClosedChannelException, .ClosedSelectorException, .DatagramChannel, .SelectionKey, .Selector, java.time.temporal.ChronoUnit, java.util.concurrent.ConcurrentLinkedQueue, .ExecutorService, .Executors, .Future, .TimeUnit, java.util.concurrent.locks.ReentrantLock, jdk.internal.net.http.common.Deadline, .Log, .Logger, .TimeLine, .TimeSource, .Utils, .Utils.UseVTForSelector, jdk.internal.net.http.quic.QuicEndpoint.QuicVirtualThreadedEndpoint, .QuicEndpoint.QuicSelectableEndpoint

A QUIC selector to select over one or several quic transport endpoints.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
QuicSelector.QuicNioSelector

A QuicSelector implementation based on non-blocking Datagram Channels and using a NIO Selector.

private static record
pack-priv static class
QuicSelector.QuicVirtualThreadPoller

A QuicSelector implementation based on blocking Datagram Channels and using a Virtual Threads to poll the channels.

Field Summary

Modifier and TypeField and Description
pack-priv final Logger
private volatile boolean
public static final long
IDLE_PERIOD_MS

The maximum timeout passed to Selector::select.

private final QuicInstance
private static final ScopedValue<Boolean>
private final String
private static final TimeLine
private final QuicSelector.QuicSelectorThread
private final QuicTimerQueue

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
public void
awaitTermination(long
the maximum time to wait for termination
timeout
,
TimeUnit
the timeout unit
unit
)

Awaits termination of the selector thread, up until the given timeout has elapsed.

public void
close()

Implements java.lang.AutoCloseable.close.

Closes this QuicSelector.

public long
public static QuicSelector<? extends QuicEndpoint>

Returns:

a new instance of QuicNioSelector
createQuicNioSelector
(QuicInstance
the quic instance
quicInstance
,
String
the selector name
name
)

Returns a new instance of QuicNioSelector.

public static QuicSelector<? extends QuicEndpoint>

Returns:

a new instance of QuicVirtualThreadPoller
createQuicVirtualThreadPoller
(QuicInstance
the quic instance
quicInstance
,
String
the selector name
name
)

Returns a new instance of QuicVirtualThreadPoller.

pack-priv boolean
done()

public static boolean
public String
name()

public void
register(T endpoint)

public final void
run()

Implements java.lang.Runnable.run.

Runs this operation.

pack-priv abstract void
public void
shutdown()

Shuts down the QuicSelector by invoking Selector#close().

public void
public QuicTimerQueue
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

debugback to summary
pack-priv final Logger debug
doneback to summary
private volatile boolean done
IDLE_PERIOD_MSback to summary
public static final long IDLE_PERIOD_MS

The maximum timeout passed to Selector::select.

instanceback to summary
private final QuicInstance instance
IS_SELECTORback to summary
private static final ScopedValue<Boolean> IS_SELECTOR
nameback to summary
private final String name
sourceback to summary
private static final TimeLine source
threadback to summary
private final QuicSelector.QuicSelectorThread thread
timerQueueback to summary
private final QuicTimerQueue timerQueue

Constructor Detail

QuicSelectorback to summary
private QuicSelector(QuicInstance instance, String name)

Method Detail

abortback to summary
public void abort(Throwable t)
awaitTerminationback to summary
public void awaitTermination(long timeout, TimeUnit unit)

Awaits termination of the selector thread, up until the given timeout has elapsed. If the current thread is the selector thread, returns immediately without waiting.

Parameters
timeout:long

the maximum time to wait for termination

unit:TimeUnit

the timeout unit

closeback to summary
public void close()

Implements java.lang.AutoCloseable.close.

Closes this QuicSelector. This method calls shutdown() and then waits for the selector thread to terminate, up to two IDLE_PERIOD_MS.

Annotations
@Override
computeNextDeadLineback to summary
public long computeNextDeadLine()
createQuicNioSelectorback to summary
public static QuicSelector<? extends QuicEndpoint> createQuicNioSelector(QuicInstance quicInstance, String name) throws IOException

Returns a new instance of QuicNioSelector.

A QuicNioSelector is an implementation of QuicSelector based on non blocking Datagram Channels and using an underlying NIO Selector.

The returned implementation can only be used with QuicSelectableEndpoint endpoints.

Parameters
quicInstance:QuicInstance

the quic instance

name:String

the selector name

Returns:QuicSelector<? extends QuicEndpoint>

a new instance of QuicNioSelector

Exceptions
IOException:
if an IOException occurs when creating the underlying Selector
createQuicVirtualThreadPollerback to summary
public static QuicSelector<? extends QuicEndpoint> createQuicVirtualThreadPoller(QuicInstance quicInstance, String name)

Returns a new instance of QuicVirtualThreadPoller. A QuicVirtualThreadPoller is an implementation of QuicSelector based on blocking Datagram Channels and using Virtual Threads to poll the datagram channels.

The returned implementation can only be used with QuicVirtualThreadedEndpoint endpoints.

Parameters
quicInstance:QuicInstance

the quic instance

name:String

the selector name

Returns:QuicSelector<? extends QuicEndpoint>

a new instance of QuicVirtualThreadPoller

doneback to summary
pack-priv boolean done()
isSelectorThreadback to summary
public static boolean isSelectorThread()
nameback to summary
public String name()
registerback to summary
public void register(T endpoint) throws ClosedChannelException
runback to summary
public final void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override
runSelectorback to summary
pack-priv abstract void runSelector()
shutdownback to summary
public void shutdown()

Shuts down the QuicSelector by invoking Selector#close(). This method doesn't wait for the selector thread to terminate.

See Also
awaitTermination(long, TimeUnit)
startback to summary
public void start()
timerback to summary
public QuicTimerQueue timer()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
wakeupback to summary
public void wakeup()
jdk.internal.net.http.quic back to summary

pack-priv final Class QuicSelector.QuicNioSelector

extends QuicSelector<QuicEndpoint.QuicSelectableEndpoint>
Class Inheritance

A QuicSelector implementation based on non-blocking Datagram Channels and using a NIO Selector. This implementation is tied to QuicSelectableEndpoint instances.

Field Summary

Modifier and TypeField and Description
pack-priv final Selector
Inherited from jdk.internal.net.http.quic.QuicSelector:
debugIDLE_PERIOD_MS

Constructor Summary

AccessConstructor and Description
private
QuicNioSelector(QuicInstance instance, Selector selector, String name)

Method Summary

Modifier and TypeMethod and Description
pack-priv boolean
public void
public void
pack-priv void
public void
public void
Inherited from jdk.internal.net.http.quic.QuicSelector:
awaitTerminationclosecomputeNextDeadLinecreateQuicNioSelectorcreateQuicVirtualThreadPollerdoneisSelectorThreadnamerunstarttimertoString

Field Detail

selectorback to summary
pack-priv final Selector selector

Constructor Detail

QuicNioSelectorback to summary
private QuicNioSelector(QuicInstance instance, Selector selector, String name)

Method Detail

abortback to summary
pack-priv boolean abort(SelectionKey key, Throwable error)
abortback to summary
public void abort(Throwable error)

Overrides jdk.internal.net.http.quic.QuicSelector.abort.

Annotations
@Override
registerback to summary
public void register(QuicEndpoint.QuicSelectableEndpoint endpoint) throws ClosedChannelException

Overrides jdk.internal.net.http.quic.QuicSelector.register.

runSelectorback to summary
pack-priv void runSelector()

Implements abstract jdk.internal.net.http.quic.QuicSelector.runSelector.

Annotations
@Override
shutdownback to summary
public void shutdown()

Overrides jdk.internal.net.http.quic.QuicSelector.shutdown.

Shuts down the QuicSelector by marking the selector done, and waking up the selector thread. Upon waking up, the selector thread will invoke Selector#close(). This method doesn't wait for the selector thread to terminate.

See Also
awaitTermination(long, TimeUnit)
wakeupback to summary
public void wakeup()

Overrides jdk.internal.net.http.quic.QuicSelector.wakeup.

jdk.internal.net.http.quic back to summary

private final Record QuicSelector.QuicSelectorThread

extends Record
Class Inheritance
Record Components
thread:Thread 

Field Summary

Modifier and TypeField and Description
private final Thread
thread

Record Component accessed by thread().

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

pack-priv void
join(long millis)

pack-priv static QuicSelector.QuicSelectorThread
of(Utils.UseVTForSelector config, QuicSelector<?> selector)

pack-priv static QuicSelector.QuicSelectorThread
ofPlatform(QuicSelector<?> selector)

pack-priv static QuicSelector.QuicSelectorThread
ofVirtual(QuicSelector<?> selector)

pack-priv void
public Thread
thread()

Record Component getter of thread.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

threadback to summary
private final Thread thread

Record Component accessed by thread().

Constructor Detail

QuicSelectorThreadback to summary
private QuicSelectorThread(Thread thread)

Method Detail

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

joinback to summary
pack-priv void join(long millis) throws InterruptedException
ofback to summary
pack-priv static QuicSelector.QuicSelectorThread of(Utils.UseVTForSelector config, QuicSelector<?> selector)
ofPlatformback to summary
pack-priv static QuicSelector.QuicSelectorThread ofPlatform(QuicSelector<?> selector)
ofVirtualback to summary
pack-priv static QuicSelector.QuicSelectorThread ofVirtual(QuicSelector<?> selector)
startback to summary
pack-priv void start()
threadback to summary
public Thread thread()

Record Component getter of thread.

toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.

jdk.internal.net.http.quic back to summary

pack-priv final Class QuicSelector.QuicVirtualThreadPoller

extends QuicSelector<QuicEndpoint.QuicVirtualThreadedEndpoint>
Class Inheritance

A QuicSelector implementation based on blocking Datagram Channels and using a Virtual Threads to poll the channels. This implementation is tied to QuicVirtualThreadedEndpoint instances.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
private final ConcurrentLinkedQueue<QuicSelector.QuicVirtualThreadPoller.EndpointTask>
private final ReentrantLock
pack-priv static final boolean
private final ExecutorService
private final Object
private volatile long
Inherited from jdk.internal.net.http.quic.QuicSelector:
debugIDLE_PERIOD_MS

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv boolean
public void
pack-priv boolean
pack-priv void
pack-priv ExecutorService
public void
pack-priv void
public void
shutdown()

Overrides jdk.internal.net.http.quic.QuicSelector.shutdown.

Shuts down the QuicSelector by invoking Selector#close().

public Future<?>
public void
Inherited from jdk.internal.net.http.quic.QuicSelector:
awaitTerminationclosecomputeNextDeadLinecreateQuicNioSelectorcreateQuicVirtualThreadPollerdoneisSelectorThreadnamerunstarttimertoString

Field Detail

endpointsback to summary
private final ConcurrentLinkedQueue<QuicSelector.QuicVirtualThreadPoller.EndpointTask> endpoints
stateLockback to summary
private final ReentrantLock stateLock
usePlatformThreadsback to summary
pack-priv static final boolean usePlatformThreads
virtualThreadServiceback to summary
private final ExecutorService virtualThreadService
waiterback to summary
private final Object waiter
wakeupsback to summary
private volatile long wakeups

Constructor Detail

QuicVirtualThreadPollerback to summary
private QuicVirtualThreadPoller(QuicInstance instance, String name)

Method Detail

abortback to summary
pack-priv boolean abort(QuicSelector.QuicVirtualThreadPoller.EndpointTask task, Throwable error)
abortback to summary
public void abort(Throwable t)

Overrides jdk.internal.net.http.quic.QuicSelector.abort.

Annotations
@Override
closeback to summary
pack-priv boolean close(QuicSelector.QuicVirtualThreadPoller.EndpointTask task)
markDoneback to summary
pack-priv void markDone()
readLoopExecutorback to summary
pack-priv ExecutorService readLoopExecutor()
registerback to summary
public void register(QuicEndpoint.QuicVirtualThreadedEndpoint endpoint) throws ClosedChannelException

Overrides jdk.internal.net.http.quic.QuicSelector.register.

Annotations
@Override
runSelectorback to summary
pack-priv void runSelector()

Implements abstract jdk.internal.net.http.quic.QuicSelector.runSelector.

Annotations
@Override
shutdownback to summary
public void shutdown()

Overrides jdk.internal.net.http.quic.QuicSelector.shutdown.

Doc from jdk.internal.net.http.quic.QuicSelector.shutdown.

Shuts down the QuicSelector by invoking Selector#close(). This method doesn't wait for the selector thread to terminate.

Annotations
@Override
startReadingback to summary
public Future<?> startReading(QuicEndpoint.QuicVirtualThreadedEndpoint endpoint)
wakeupback to summary
public void wakeup()

Overrides jdk.internal.net.http.quic.QuicSelector.wakeup.

Annotations
@Override
jdk.internal.net.http.quic back to summary

pack-priv final Class QuicSelector.QuicVirtualThreadPoller.EndpointTask

extends Object
implements Runnable
Class Inheritance
  • java.lang.Object
  • jdk.internal.net.http.quic.QuicSelector.QuicVirtualThreadPoller.EndpointTask
All Implemented Interfaces
java.lang.Runnable

Field Summary

Modifier and TypeField and Description
pack-priv final QuicEndpoint.QuicVirtualThreadedEndpoint
pack-priv final ConcurrentLinkedQueue<QuicSelector.QuicVirtualThreadPoller.EndpointTask>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

EndpointTaskback to summary
pack-priv EndpointTask(QuicEndpoint.QuicVirtualThreadedEndpoint endpoint, ConcurrentLinkedQueue<QuicSelector.QuicVirtualThreadPoller.EndpointTask> endpoints)

Method Detail

runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override