Skip to content

Example of waiting for Event Objects by associating them with a I/O Completion Port (IOCP), effectively lifting MAXIMUM_WAIT_OBJECTS (64) limit of WaitForMultipleObjects(Ex) API.

Notifications You must be signed in to change notification settings

whindsaks/win32-iocp-events

 
 

Repository files navigation

Win32: Processing Event Objects through I/O Completion Port

Example of waiting for Event Objects by associating them with a I/O Completion Port (IOCP), effectively lifting MAXIMUM_WAIT_OBJECTS limit of WaitForMultipleObjects(Ex) API.

The problem

Sometimes programs need to wait for a lot of objects. But WaitForMultipleObjects(Ex) APIs are limited to 64 (MAXIMUM_WAIT_OBJECTS). To work around this limit, programs have to resolve to various complicated solutions, like starting multiple threads, refactor their logic, etc.

The limited solution

Up until Windows 8 the Thread Pool API wait operation too used multiple threads. This is inefficient so it was refactored to use internal NtAssociateWaitCompletionPacket call.

You can now wait for thousands of events, but only in a threadpool. If your program for some reason can't (isn't thread-safe, or uses own IOCP), you were out of luck.

The full solution

The full solution is to use that internal, barely documented, APIs. This repository shows how.

Notes

  • The API supports waiting for Semaphores, Threads and Processes, not just Events.

Resources

About

Example of waiting for Event Objects by associating them with a I/O Completion Port (IOCP), effectively lifting MAXIMUM_WAIT_OBJECTS (64) limit of WaitForMultipleObjects(Ex) API.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 77.8%
  • C 22.2%