Reimplementing sun.nio.ch.WindowsSelectorImpl using WSAEventSelect and WSAWaitForMultipleEvents instead of a wakeup socket

David Lloyd david.lloyd at redhat.com
Mon May 21 13:44:22 UTC 2018


The correct list is nio-dev at openjdk.java.net, which I am forwarding
this message to.  This sounds interesting though.

On Fri, May 18, 2018 at 10:23 PM, John Platts <john_platts at hotmail.com> wrote:
> The need to allocate a wakeup socket can be eliminated in sun.nio.ch.WindowsSelectorImpl on Windows platforms by reimplementing sun.nio.ch.WindowsSelectorImpl to use the WSAEventSelect and WSAWaitForMultipleEvents APIs introduced in Windows Vista. If WSAEventSelect and WSAWaitForMultipleEvents are used, a wakeup can be done by simply signaling the wakeup event by calling WSASetEvent.
>
> Here is how to do a select using WSAEventSelect and WSAWaitForMultipleEvents on Windows platforms:
> 1. Allocate events for selection and wakeup by calling the WSACreateEvent() function.
> 2. Perform a select operation by calling WSAEventSelect method, passing in the event object used for selection.
> 3. Call the WSAWaitForMultipleEvents function to wait until one of the events is signaled.
> 4. For the remaining events, call WSAWaitForMultipleEvents with a timeout of 0 to check if the event is signaled.
> 5. For each of the selection events that are signaled, call the WSAEnumNetworkEvents method to check if the socket is ready for accept, connect, read, or write operations.
> 6. To cancel selection, call WSAEventSelect with 0 passed into the lNetworkEvents argument (the third argument).
> 7. Free the events allocated by the WSACreateEvent() function by calling the WSACloseEvent() function.



-- 
- DML


More information about the nio-dev mailing list