WSAWaitForMultipleEvents from multiple threads
I'm thinking of changing my server code over to use WSAEventSelect. I was going to have 2*num_cpu threads handling the event processing, and the easiest way I thought to do this was a bit like IO completion ports; have the threads all waiting for an event and get one to dequeue one. However, I suspect that when one of the sockets becomes signalled, all the threads will leap into action, correct?
What would be the best (most efficient) way of handling this? I could have one thread for every 512 sockets, or something like that, but I'm not sure what the best way actually is.
Also, is there a limit to the number of events you can pass to WSAWaitForMultipleEvents? There isn't one mentioned, but I suspect that trying to wait for 65535 events would be A Bad Thing...
If the event is auto-reset, then only one thread will start running when it is pulsed.
However, emulating IOCP when IOCP is already there seems kind-of pointless (but no doubt fun to get to work :-)
However, emulating IOCP when IOCP is already there seems kind-of pointless (but no doubt fun to get to work :-)
Quote:Original post by kuphrynWah! That's only 64 handles. That'll be a lot of threads... I might just go back to look at my IOCP code I think. I'll try to get a really simple test application running so I can get all you to debug it for me [wink]
Correct.
WSA_MAXIMUM_WAIT_EVENTS
Thanks for the replies.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement