ladybird
ladybird copied to clipboard
LibCore: Use IOCPs for the event loop on windows
This PR introduces an IOCP based implementation of the event loop. Currently only one thread is used to wait. The number of threads to use and the number of entries to remove at once will probably need to be tuned. For a more exhuastive description see the commit message. As a drive by use a stack buffer to format windows errors as allocation fails during program destruction.
There is some additional complexity here as we are doing something very unintended. Io completion ports as the name suggest notify on completion. Using the nt kernel apis we are able to wait on an event as well. As such we are able to use WSAEventSelect to associate an event with a socket and get a select like api that notifies us when a socket is readable. However, doing this is not possible for files, so this model cannot be used for file IO. To implement async file IO we would need to switch to a completion notification model but that seems impossible for all platforms and even if it was there would be a very large maintenance burden associated with maintaining multiple implementations. Some more details both about the implementation and how bad moving to a completion model would be are in #ui-windows on discord.
Your pull request has conflicts that need to be resolved before it can be reviewed and merged. Make sure to rebase your branch on top of the latest master.
Before merging this it still needs implementing accessing another thread's event loop. Edit: not applicable anymore
Your pull request has conflicts that need to be resolved before it can be reviewed and merged. Make sure to rebase your branch on top of the latest master.