Top Description Inners Fields Constructors Methods
org.newsclub.net.unix

pack-priv final Class VirtualThreadPollerNaive

extends Object
implements VirtualThreadPoller
Class Inheritance
All Implemented Interfaces
org.newsclub.net.unix.VirtualThreadPoller
Imports
java.io.Closeable, .FileDescriptor, .IOException, .InterruptedIOException, java.net.SocketTimeoutException, java.util.LinkedList, .List, .Map, java.util.concurrent.ConcurrentHashMap, .ExecutionException, java.util.concurrent.locks.LockSupport, org.eclipse.jdt.annotation.Nullable, org.newsclub.net.unix.AFSelector.PollFd

"Naive" implementation of VirtualThreadPoller, using NativeUnixSocket#poll(PollFd, int) on non-virtual threads.
Author
Christian Kohlschütter

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private static final InterruptedIOException
private static final int
private static final Map<FileDescriptor, VirtualThreadPollerNaive.PollJob>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
parkThreadUntilReady(FileDescriptor
The file descriptor to check.
fd
,
int mode, long
The refence time (in millis) for the timeout
now
,
AFSupplier<Integer>
(in seconds), or 0 for infinite
timeout
,
Closeable
Callback to call upon interrupt (usually to close the resource working on the file descriptor)
closeOnInterrupt
)

Implements org.newsclub.net.unix.VirtualThreadPoller.parkThreadUntilReady.

Parks the current thread until the given file descriptor is ready, with respect to the given readiness mode.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

POLL_INTERRUPTED_SENTINELback to summary
private static final InterruptedIOException POLL_INTERRUPTED_SENTINEL
POLL_INTERVAL_MILLISback to summary
private static final int POLL_INTERVAL_MILLIS
POLL_JOBSback to summary
private static final Map<FileDescriptor, VirtualThreadPollerNaive.PollJob> POLL_JOBS

Constructor Detail

VirtualThreadPollerNaiveback to summary
pack-priv VirtualThreadPollerNaive()

Method Detail

parkThreadUntilReadyback to summary
public void parkThreadUntilReady(FileDescriptor fd, int mode, long now, AFSupplier<Integer> timeout, Closeable closeOnInterrupt) throws IOException

Implements org.newsclub.net.unix.VirtualThreadPoller.parkThreadUntilReady.

Doc from org.newsclub.net.unix.VirtualThreadPoller.parkThreadUntilReady.

Parks the current thread until the given file descriptor is ready, with respect to the given readiness mode.

Parameters
fd:FileDescriptor

The file descriptor to check.

mode:int

The mode (bitmask of SelectionKey#OP_READ, SelectionKey#OP_WRITE, SelectionKey#OP_ACCEPT, SelectionKey#OP_CONNECT)

now:long

The refence time (in millis) for the timeout

timeout:AFSupplier<Integer>

(in seconds), or 0 for infinite

closeOnInterrupt:Closeable

Callback to call upon interrupt (usually to close the resource working on the file descriptor)

Annotations
@Override
Exceptions
IOException:
on other error
org.newsclub.net.unix back to summary

private final Class VirtualThreadPollerNaive.PollJob

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final FileDescriptor
private final int
private final long
private final AFSupplier<Integer>
private final List<Thread>

Constructor Summary

AccessConstructor and Description
pack-priv
PollJob(FileDescriptor fd, int mode, long now, AFSupplier<Integer> timeout)

Method Summary

Modifier and TypeMethod and Description
pack-priv AFFuture<@Nullable IOException>
trigger(Thread waitingThread)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

fdback to summary
private final FileDescriptor fd
modeback to summary
private final int mode
nowback to summary
private final long now
timeoutback to summary
private final AFSupplier<Integer> timeout
waitingThreadsback to summary
private final List<Thread> waitingThreads

Constructor Detail

PollJobback to summary
pack-priv PollJob(FileDescriptor fd, int mode, long now, AFSupplier<Integer> timeout)

Method Detail

triggerback to summary
pack-priv AFFuture<@Nullable IOException> trigger(Thread waitingThread)
Annotations
@SuppressWarnings:PMD.CognitiveComplexity