Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In Windows, async operations are done by file operation, not by descriptor. There are several ways to wait on file operations to complete asynchronously.</p> <p>For example, if you want to know when data is available on a network socket, issue an async read request on the socket and when it completes, the data was available and was retrieved.</p> <p>In Win32, async operations use the <a href="http://msdn.microsoft.com/en-us/library/ms684342(VS.85).aspx" rel="nofollow noreferrer"><code>OVERLAPPED</code></a> structure to contain state about an outstanding IO operation.</p> <ol> <li>Associate the files with an <a href="http://msdn.microsoft.com/en-us/library/aa365198(VS.85).aspx" rel="nofollow noreferrer">IO Completion Port</a> and dispatch async IO requests. When an operation completes, it will put a completion message on the queue which your worker thread(s) can wait on and retrieve as they arrive. You can also put user defined messages into the queue. There is no limit to how many files or queued messages can be used with a completion port</li> <li>Dispatch each IO operation with an event. The event associated with an operation will become signaled (satisfy a wait) when it completes. Use <a href="http://msdn.microsoft.com/en-us/library/ms687025(VS.85).aspx" rel="nofollow noreferrer"><code>WaitForMultipleObjects</code></a> to wait on all the events at once. This has the disadvantage of only being able to wait on <code>MAXIMUM_WAIT_OBJECTS</code> objects at once (64). You can also wait on other types of events at the same time (process/thread termination, mutexes, events, semaphores)</li> <li>Use a <a href="http://msdn.microsoft.com/en-us/library/ms686760(VS.85).aspx" rel="nofollow noreferrer">thread pool</a>. The thread pool can take an unlimited number of objects and file operations to wait on and execute a <a href="http://msdn.microsoft.com/en-us/library/ms684124(VS.85).aspx" rel="nofollow noreferrer">user defined function</a> upon completion each.</li> <li>Use <code><a href="http://msdn.microsoft.com/en-us/library/aa365468(VS.85).aspx" rel="nofollow noreferrer">ReadFileEx</a></code> and <a href="http://msdn.microsoft.com/en-us/library/aa365748(VS.85).aspx" rel="nofollow noreferrer"><code>WriteFileEx</code></a> to queue <a href="http://msdn.microsoft.com/en-us/library/ms681951(VS.85).aspx" rel="nofollow noreferrer">Asynchronous Procedure Calls</a> (APCs) to the calling thread and <a href="http://msdn.microsoft.com/en-us/library/ms686307(VS.85).aspx" rel="nofollow noreferrer"><code>SleepEx</code></a> (or <code>WaitFor{Single|Multiple}ObjectsEx</code>) with <code>Alertable TRUE</code> to receive a notification message for each operation when it completes. This method is similar to an IO completion port, but only works for one thread. </ol> <p>The Windows NT kernel makes no distinction between socket, disk file, pipe, etc. file operations internally: all of these options will work with all the file types.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload