< prev index next >

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

Print this page
*** 140,10 ***
--- 140,24 ---
          } else {
              assert false;
          }
      }
  
+     /**
+      * Parks the current thread until a Selector's file descriptor is ready.
+      * @param fdVal the Selector's file descriptor
+      * @param nanos the waiting time or 0 to wait indefinitely
+      */
+     static void pollSelector(int fdVal, long nanos) throws IOException {
+         assert nanos >= 0L;
+         Poller poller = POLLERS.masterPoller();
+         if (poller == null) {
+             poller = POLLERS.readPoller(fdVal);
+         }
+         poller.poll(fdVal, nanos, () -> true);
+     }
+ 
      /**
       * If there is a thread polling the given file descriptor for the given event then
       * the thread is unparked.
       */
      static void stopPoll(int fdVal, int event) {

*** 337,10 ***
--- 351,17 ---
                      startPlatformThread("Write-Poller", p::pollerLoop);
                  });
              }
          }
  
+         /**
+          * Returns the master poller, or null if there is no master poller.
+          */
+         Poller masterPoller() {
+             return masterPoller;
+         }
+ 
          /**
           * Returns the read poller for the given file descriptor.
           */
          Poller readPoller(int fdVal) {
              int index = provider.fdValToIndex(fdVal, readPollers.length);
< prev index next >