mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-10-06 07:00:16 +08:00
Dispatch() resolves the handler through a map keyed by the descriptor stored in epoll_event::data, which means taking a lock for every event dispatched, on the thread running the event loop. Point epoll_event::data.ptr at a small dispatcher-owned entry holding the handler instead. Unregistering clears the handler in the entry rather than freeing it, since a batch being dispatched may still point at one, so the entries live as long as the dispatcher and are indexed by descriptor. Dispatch() then reaches the handler through the pointer epoll_wait() gave back and never looks at the container at all, so it takes no lock. The lock that remains guards only the growth of the vector, from registrations made on worker threads. This also makes the RegisterFD()/ModifyFD() disagreement noted in the map version a non-issue: an entry is created on demand by either path. No behaviour change, and the test added with the map version passes unchanged. Closes #26930.