< prev index next >

src/java.base/share/classes/sun/nio/ch/SelChImpl.java

Print this page

        

*** 29,38 **** --- 29,40 ---- import java.io.FileDescriptor; import java.io.IOException; import static java.util.concurrent.TimeUnit.NANOSECONDS; + import jdk.internal.misc.Strands; + /** * An interface that allows translation (and more!). * * @since 1.4 */
*** 69,79 **** int translateInterestOps(int ops); void kill() throws IOException; /** ! * Disables the current thread for scheduling purposes until this * channel is ready for I/O, or asynchronously closed, for up to the * specified waiting time. * * <p> This method does <em>not</em> report which of these caused the * method to return. Callers should re-check the conditions which caused --- 71,81 ---- int translateInterestOps(int ops); void kill() throws IOException; /** ! * Disables the current thread or fiber for scheduling purposes until this * channel is ready for I/O, or asynchronously closed, for up to the * specified waiting time. * * <p> This method does <em>not</em> report which of these caused the * method to return. Callers should re-check the conditions which caused
*** 81,101 **** * * @param event the event to poll * @param nanos the timeout to wait; {@code <= 0} to wait indefinitely */ default void park(int event, long nanos) throws IOException { ! long millis; ! if (nanos <= 0) { ! millis = -1; } else { ! millis = NANOSECONDS.toMillis(nanos); } - Net.poll(getFD(), event, millis); } /** ! * Disables the current thread for scheduling purposes until this * channel is ready for I/O, or asynchronously closed. * * <p> This method does <em>not</em> report which of these caused the * method to return. Callers should re-check the conditions which caused * the thread to park. --- 83,119 ---- * * @param event the event to poll * @param nanos the timeout to wait; {@code <= 0} to wait indefinitely */ default void park(int event, long nanos) throws IOException { ! Object strand = Strands.currentStrand(); ! if (PollerProvider.available() && (strand instanceof Fiber)) { ! Poller.register(strand, getFDVal(), event); ! if (isOpen()) { ! try { ! if (nanos == 0) { ! Strands.parkFiber(); ! } else { ! Strands.parkFiber(nanos); ! } ! } finally { ! Poller.deregister(strand, getFDVal(), event); ! } ! } } else { ! long millis; ! if (nanos == 0) { ! millis = -1; ! } else { ! millis = NANOSECONDS.toMillis(nanos); ! } ! Net.poll(getFD(), event, millis); } } /** ! * Disables the current thread or fiber for scheduling purposes until this * channel is ready for I/O, or asynchronously closed. * * <p> This method does <em>not</em> report which of these caused the * method to return. Callers should re-check the conditions which caused * the thread to park.
*** 103,109 **** * @param event the event to poll */ default void park(int event) throws IOException { park(event, 0L); } - } --- 121,126 ----
< prev index next >