compio-rs / compio

A thread-per-core Rust runtime with IOCP/io_uring/polling.
MIT License
420 stars 37 forks source link

feat(driver,windows): add win32 event support #223

Closed Berrysoft closed 7 months ago

Berrysoft commented 7 months ago

This PR adds Win32 event support for IOCP driver. Win32 event is kind of foundamental syncronize object. It could be, e.g., an event handle, an input console handle, a pipe handle, or a mutex handle.

Win32 event could not be polled by IOCP, but IOCP could be waited as a usual event on Windows 10+. MsgWaitForMultipleObjectsEx is used here to wait them all, and reserves possibility for APC routines and window messages. If there are more than 62 events to be waited, the remain events will be waited in seperate threads.

In this PR, stdio is also refactored to use the new feature. To make the code simpler, the console code page is forced to UTF8.

This PR is a prediction of the planned compio-process. We need the feature to wait for the process handle.

Berrysoft commented 7 months ago

@George-Miao may feel hard to review code for Windows. @bdbai would you like to take a look?

Berrysoft commented 7 months ago

Impl changed to use thread pool API instead. According to Raymond Chen, it handles more than 64 events in a single thread.