Top Description Fields Methods
org.newsclub.net.unix

pack-priv Interface VirtualThreadPoller

Known Direct Implementers
org.newsclub.net.unix.VirtualThreadPollerNaive
Imports
java.io.Closeable, .FileDescriptor, .IOException, java.net.SocketTimeoutException, java.nio.channels.SelectionKey

Helper class to support polling "virtually blocked" file descriptors for virtual threads.
Author
Christian Kohlschütter

Field Summary

Modifier and TypeField and Description
public static final VirtualThreadPoller
INSTANCE

Returns the default instance best suited for the current system.

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
)

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

Field Detail

INSTANCEback to summary
public static final VirtualThreadPoller INSTANCE

Returns the default instance best suited for the current system.

Method Detail

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

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)

Exceptions
IOException:
on other error
SocketTimeoutException:
on timeout
SocketClosedByInterruptException:
on interrupt.