CFRunLoop and NSRunLoop are objects which represent the infinite loop associated with each thread for listening to input sources, timers, etc. and execute them when the event arrives. It is also known as event loops outside Apple.
Run loop modes
Every thread has exactly one run loop, but each run loop has multiple modes. Every input source can be added to one or more modes, and when that mode is run, only those sources will be listened.
The following are some run loop modes:
Mode | Purpose | Part of common modes? |
---|---|---|
kCFRunLoopDefaultMode | The default run loop mode, almost encompasses every sources. You should always add sources and timers to this mode if there's no special reasons. Can be accessed with the symbol kCFRunLoopDefaultMode and NSDefaultRunLoopMode. | Yes |
NSTaskDeathCheckMode | Used by NSTask to check if the task is still running. | Yes |
_kCFHostBlockingMode _kCFNetServiceMonitorBlockingMode _kCFNetServiceBrowserBlockingMode _kCFNetServiceBlockingMode _kCFStreamSocketReadPrivateMode _kCFStreamSocketCanReadPrivateMode _kCFStreamSocketWritePrivateMode _kCFStreamSocketCanWritePrivateMode _kCFStreamSocketSecurityClosePrivateMode _kCFStreamSocketBogusPrivateMode _kCFURLConnectionPrivateRunLoopMode _kProxySupportLoadingPacPrivateMode _kProxySupportSyncPACExecutionRunLoopMode _kCFStreamSocketSecurityClosePrivateMode |
Various private run loop modes used by CFNetwork for blocking operations | No |
UITrackingRunLoopMode | UI tracking. | Yes |
GSEventReceiveRunLoopMode | Receiving system events. | No |
com.apple.securityd.runloop | Communication with securityd. Used by SpringBoard only. | No |
FigPlayerBlockingRunLoopMode | QuickTime related. | No |
External links
- Official reference: http://developer.apple.com/iphone/library/documentation/CoreFoundation/Reference/CFRunLoopRef/Reference/reference.html [Archived 2009-07-21 at the Wayback Machine]