以下为主RunLoop 的输出,能够看到不同的source0,source1,observer

----------------------------------

CFRunLoop{wakeup port =, stopped = false, ignoreWakeUps = false, 
current mode = kCFRunLoopDefaultMode,
common modes

{
  <CFString 0x108f42000 [0x107bd39b0]>{contents = "UITrackingRunLoopMode"}
  <CFString 0x107ba9800 [0x107bd39b0]>{contents = "kCFRunLoopDefaultMode"}
}

common mode items 

(
   <CFRunLoopSource>{callout = PurpleEventSignalCallback}}
  <CFRunLoopObserver>{callout = _wrapRunLoopWithAutoreleasePoolHandler}
   <CFRunLoopSource>{callout = FBSSerialQueueRunLoopSourceHandler}}
  <CFRunLoopObserver>{callout = _beforeCACommitHandler}
  <CFRunLoopSource>{callout = __handleHIDEventFetcherDrain}}
  <CFRunLoopObserver>{callout = _wrapRunLoopWithAutoreleasePoolHandler}
  <CFRunLoopObserver>{callout = _afterCACommitHandler}
  <CFRunLoopObserver>{callout = _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv}
  <CFRunLoopSource>{callout = __handleEventQueue}
  <CFRunLoopObserver>{callout = _UIGestureRecognizerUpdateObserver}
  <CFRunLoopSource>{<CFRunLoopSource MIG Server> {port = 17927, subsystem = 0x108ef9998, context = 0x0}}
  <CFRunLoopSource>{callout = PurpleEventCallback}}
  <CFRunLoopSource>{callout = _ZL27change_notify_port_callbackP12__CFMachPortPvlS1_}
  <CFRunLoopTimer>{callout = _ZN2CAL14timer_callbackEP16__CFRunLoopTimerPv}
  <CFRunLoopSource>{<CFRunLoopSource MIG Server> {port = 22535, subsystem =, context =}}
  <CFRunLoopSource>{<CFRunLoopSource MIG Server> {port = 40455, subsystem =, context =}}

)

1) <CFRunLoopMode>{name = UITrackingRunLoopMode, port set = 0x1e07, queue =, source =, timer port = 0x2003}

sources0
(
  <CFRunLoopSource>{callout = PurpleEventSignalCallback}
  <CFRunLoopSource>{callout = __handleEventQueue}
  <CFRunLoopSource>{callout = __handleHIDEventFetcherDrain}
  <CFRunLoopSource>{callout = FBSSerialQueueRunLoopSourceHandler}
)

sources1
(
  <CFRunLoopSource>{<CFRunLoopSource MIG Server>}
  <CFRunLoopSource>{CFMachPort{callout = _ZL27change_notify_port_callbackP12__CFMachPortPvlS1_}}
  <CFRunLoopSource>{<CFRunLoopSource MIG Server>}
  <CFRunLoopSource>{<CFRunLoopSource MIG Server>}
  <CFRunLoopSource>{callout = PurpleEventCallback}
)

observers
(
    <CFRunLoopObserver>{activities = 0x1, repeats = Yes, callout = _wrapRunLoopWithAutoreleasePoolHandler}
    <CFRunLoopObserver>{activities = 0x20, repeats = Yes, callout = _UIGestureRecognizerUpdateObserver}
    <CFRunLoopObserver>{activities = 0xa0, repeats = Yes, callout = _beforeCACommitHandler}
    <CFRunLoopObserver>{activities = 0xa0, repeats = Yes, callout = _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv}
    <CFRunLoopObserver>{activities = 0xa0, repeats = Yes, callout = _afterCACommitHandler}
    <CFRunLoopObserver>{activities = 0xa0, repeats = Yes, callout = _wrapRunLoopWithAutoreleasePoolHandler}
)

timers
(
  <CFRunLoopTimer>{callout = _ZN2CAL14timer_callbackEP16__CFRunLoopTimerPv},
)

2) <CFRunLoopMode>{name = GSEventReceiveRunLoopMode, port set = 0x2d03, queue =, source =, timer port = 0x5303}

sources0
(
  <CFRunLoopSource>{callout = PurpleEventSignalCallback}
)

sources1
(
  <CFRunLoopSource>{callout = PurpleEventCallback}
)

3) <CFRunLoopMode>{name = kCFRunLoopDefaultMode, port set = 0x1b03, queue =, source =, timer port = 0x2503}

sources0
(
  <CFRunLoopSource>{callout = PurpleEventSignalCallback}
  <CFRunLoopSource>{callout = __handleEventQueue}
  <CFRunLoopSource>{callout = __handleHIDEventFetcherDrain}
  <CFRunLoopSource>{callout = FBSSerialQueueRunLoopSourceHandler}
)

sources1
(
  <CFRunLoopSource>{<CFRunLoopSource MIG Server> {port = 17927, subsystem =, context = 0x0}}
  <CFRunLoopSource>{callout = _ZL27change_notify_port_callbackP12__CFMachPortPvlS1_}
  <CFRunLoopSource>{<CFRunLoopSource MIG Server> {port = 22535, subsystem =, context =}}
  <CFRunLoopSource>{<CFRunLoopSource MIG Server> {port = 40455, subsystem =, context =}}
  <CFRunLoopSource>{callout = PurpleEventCallback}
)

observers
(
  <CFRunLoopObserver>{activities = 0x1, repeats = Yes, callout = _wrapRunLoopWithAutoreleasePoolHandler}
  <CFRunLoopObserver>{activities = 0x20, repeats = Yes, callout = _UIGestureRecognizerUpdateObserver}
  <CFRunLoopObserver>{activities = 0xa0, repeats = Yes, callout = _beforeCACommitHandler}
  <CFRunLoopObserver>{activities = 0xa0, repeats = Yes, callout = _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv}
  <CFRunLoopObserver>{activities = 0xa0, repeats = Yes, callout = _afterCACommitHandler}
  <CFRunLoopObserver>{activities = 0xa0, repeats = Yes, callout = _wrapRunLoopWithAutoreleasePoolHandler
)

timers
(
  <CFRunLoopTimer>{callout = _ZN2CAL14timer_callbackEP16__CFRunLoopTimerPv}
)

4) <CFRunLoopMode]>{name = kCFRunLoopCommonModes, port set = 0x470f, queue =, source =, timer port = 0xa907}


  • 观察者

typedef enum CFRunLoopActivity : CFOptionFlags {
kCFRunLoopEntry = (1UL << 0),
kCFRunLoopBeforeTimers = (1UL << 1),
kCFRunLoopBeforeSources = (1UL << 2),
kCFRunLoopBeforeWaiting = (1UL << 5),
kCFRunLoopAfterWaiting = (1UL << 6),
kCFRunLoopExit = (1UL << 7),
kCFRunLoopAllActivities = 0x0FFFFFFFU
} CFRunLoopActivity;
  • <<<<<<主线程RunLoop 用到的 Activity>>>>>>
0x01 == 00000001 ===>>> kCFRunLoopEntry
0x20 == 00100000 ===>>> kCFRunLoopBeforeWaiting
0xa0 == 10100000 ===>>> kCFRunLoopBeforeWaiting | kCFRunLoopExit

 

  • autorelease pool : _wrapRunLoopWithAutoreleasePoolHandler: 主消息循环在进入和等待或者退出注册了handler,来处理自动释放池
 
05-08 08:08