ObjFW  View Ticket

Ticket UUID: 31d9fb57cc9a777a67dd60bfc14462f838ed42f9
Title: OFRunLoop: Only use OFKernelEventObserver if we have sockets
Status: Open Type: Nice_To_Have
Severity: Important Priority: Immediate
Subsystem: Resolution:
Last Modified: 2020-06-22 00:37:54
Version Found In: Milestone: 1.0
User Comments:
js added on 2020-06-22 00:37:54:

OFRunLoop currently always uses OFKernelEventObserver if ObjFW is compiled with support for sockets and OFKernelEventObserver initializes the network in its +[initialize]. On some systems (e.g. Wii), initializing the network takes quite a while, resulting in quite a lengthy startup time when the main run loop is initialized.

It would be much better to only initialize OFKernelEventObserver once a socket is added to the run loop, and always fall back to using conditions until a socket is added. At which point sockets are already initialized anyway and select() and similar are available.

This could even be improved further on some systems by asynchronously initializing sockets: Sockets initialization could be started asynchronously early on, and the synchronous sockets initialization used by many classes could then just wait for the async initialization to be done. This would allow to have all non-socket code running without delay, and possibly sockets already being initialized by the time the application wants to use them, instead of only starting initialization once the application wants to use sockets.