title: Equivalent of select or poll for pipes on Windows
body: <p>Some Unix code I am working on depends on being able to <code>poll</code> over a small number of pipes. <a href="http://pubs.opengroup.org/onlinepubs/009695399/functions/poll.html" rel="nofollow noreferrer"><code>poll</code></a> is a POSIX system call that (much like the older <a href="http://pubs.opengroup.org/onlinepubs/007908775/xsh/select.html" rel="nofollow noreferrer"><code>select</code></a>) allows the process to wait until one or more file descriptors is "ready" for reading or writing, which means one can proceed to do so without blocking. This is useful to implement event loops where waiting is clearly separated from the rest of the communication.</p>
  
  <p>Is it possible to do the same for Windows pipe handles - wait for one or more of them to become "ready" for reading/writing?</p>
  
  <p>Existing SO advice on the matter, such as answers to <a href="https://stackoverflow.com/questions/38277148/equivalent-of-select-for-pipes-on-windows">this question</a>, recommend the use of completion ports. However as far as I can tell, completion ports require <em>initiating</em> reading/writing beforehand, and then waiting for (or being notified of) the completion of those operations. This approach does not fit the architecture of the code, which strongly separates the polling code from the reading/writing code, the latter calling into a library that uses the regular <code>ReadFile</code> and <code>WriteFile</code> on the underlying handle.</p>
  
  <p>If there is no direct equivalent to <code>poll</code>, could one abuse completion ports to provide something similar? In other words, is it possible to create IO completion events that announce "you can now call <code>ReadFile</code> (<code>WriteFile</code>) on this handle without it blocking" and wait for them using <code>WaitForMultipleObjects</code> or <code>GetQueuedCompletionStatus</code>?</p>