Den 2. nov. 2012 kl. 23:14 skrev Antoine Pitrou email@example.com:
On Fri, 2 Nov 2012 22:29:09 +0100 Sturla Molden firstname.lastname@example.org wrote:
IOCP might be the easiest way to get high performance on Windows, but certainly not the only.
IOCP is a simple user-space wrapper for a thread-pool and overlapped (i.e. asynchronous) i/o. There is nothing IOCP can do that cannot be done with a pool of threads and non-blocking read or write operations.
Windows certainly has a function to select among multiple wait objects, called WaitForMultipleObjects. If open files are associated with event objects signalling "ready-to-read" or "ready-to-write", that is the basic machinery of an Unix select() function.
Hmm, but the basic problem with WaitForMultipleObjects is that it has a hard limit of 64 objects you can wait on.
So you nest them in a tree, each node having up to 64 children...
The root allows us to wait for 64 objects, the first branch allows us to wait for 4096, and the second 262144...
For example, if 4096 wait objects are enough, we can use a pool of 64 threads. Each thread calls WaitForMultipleObjects on up to 64 wait objects, and signals to the master when it wakes up.