Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Increasing MAXIMUM_WAIT_OBJECTS for WaitforMultipleObjects

What is the simplest way to wait for more objects than MAXIMUM_WAIT_OBJECTS? MSDN lists this:

  • Create a thread to wait on MAXIMUM_WAIT_OBJECTS handles, then wait on that thread plus the other handles. Use this technique to break the handles into groups of MAXIMUM_WAIT_OBJECTS.
  • Call RegisterWaitForSingleObject to wait on each handle. A wait thread from the thread pool waits on MAXIMUM_WAIT_OBJECTS registered objects and assigns a worker thread after the object is signaled or the time-out interval expires.

But neither are them are very clear. The situation would be waiting for an array of over a thousand handles to threads.

like image 780
Jake Avatar asked Feb 27 '11 23:02

Jake


1 Answers

If you find yourself waiting on tons of objects you might want to look into IO Completion Ports instead. For large numbers of parallel operations IOCP is much more efficient.

And the name IOCP is misleading, you can easily use IOCP for your own synchronization structures as well.

like image 71
COrthbandt Avatar answered Sep 28 '22 07:09

COrthbandt