1.OCå
å管ç-runloop
OCå å管ç-runloop
JD茅台溯源码 RunLoop æ¯éè¿å é¨ç»´æ¤ç äºä»¶å¾ªç¯( Event Loop )æ¥å¯¹ äºä»¶/æ¶æ¯è¿è¡ç®¡ççä¸ä¸ªå¯¹è±¡ãJD茅台溯源码runloop çå®æ¹ææ¡£å¨ thread ç¯ç« Run Loops ï¼ä¹å°±ä»ä¾§é¢è¯´æäº runloop æ¯ä¸çº¿ç¨æ¯æ¯ç¸å ³çã
JD茅台溯源码å®æ¹æå¦ä¸ä¸å¼ å¾ï¼
JD茅台溯源码线ç¨çè¾å ¥æº:
JD茅台溯源码线ç¨é对è¾å ¥æºçå¤çæºå¶ï¼
JD茅台溯源码æ以ä¸æ¡ä¾ï¼
JD茅台溯源码timer ä¸ performSelector 对åºçåè°é½æ¯ __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ ï¼
JD茅台溯源码block å¯¹åº __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ ï¼
JD茅台溯源码主线ç¨å¯¹åº __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ :
JD茅台溯源码ç³»ç»è§¦æ¸äºä»¶å¯¹åº __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ ï¼
JD茅台溯源码éç¥äºä»¶å¯¹åº __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ ï¼
JD茅台溯源码å°ç»ï¼
JD茅台溯源码æ»å¨é¡µé¢è¾åºï¼
JD茅台溯源码页é¢æ»å¨è¿ç¨ä¸å¤äº UITrackingRunLoopMode ï¼éæ¢ç¶æå¤äº kCFRunLoopDefaultMode ã
JD茅台溯源码è¾åºï¼
JD茅台溯源码è¾åºï¼
JD茅台溯源码æ¢ç¶ runloop æ¯ä¸ä¸ªäºä»¶å¾ªç¯ï¼é£ä¹å®ä¸æ®éç循ç¯æä»ä¹åºå«å¢ï¼
JD茅台溯源码æ®é循ç¯ï¼
JD茅台溯源码runloop 循ç¯ï¼
JD茅台溯源码é£ä¹å¯ä»¥å¾å°ä»¥ä¸ç»è®ºï¼
JD茅台溯源码é£ä¹ runloop æ¯æä¹åå°çå¢ï¼
JD茅台溯源码é常æ们ä¼éè¿ NSRunLoop å»è·åå½åç runloop ï¼
JD茅台溯源码å®ä¹å¦ä¸ï¼
JD茅台溯源码ç» currentRunLoop ä¸ç¬¦å·æç¹ï¼
JD茅台溯源码éè¿ä¹åçåæå·²ç»å®ä½å°äº runloop æ¯å¨ CoreFoundation ä¸ç CoreFoundationæºç ãæ£å¥½ CoreFoundation å¼æºäº CFRunLoop ï¼
JD茅台溯源码é£ä¹æ ¸å¿é»è¾å°±å¨ CFRunLoopRunSpecific ä¸ãè¿æä¸ä¸ªçé®æ¯ runloop å¯ä»¥ä¼ç ï¼é£ä¹å®æ¯å¦ä½å®ç°çå¢ï¼
JD茅台溯源码è¦äºè§£ runloop çå®ç°åçï¼é¦å è¦æ¸ æ¥å®çæ°æ®ç»æã
JD茅台溯源码CFRunLoopRunSpecific ç第ä¸ä¸ªåæ°æ¯ CFRunLoopGetCurrent() ï¼
JD茅台溯源码_CFRunLoopGet0
JD茅台溯源码CFRunLoopRef çå®ä¹å¦ä¸ï¼
JD茅台溯源码å®é ä¸åºå±å®æ¯ __CFRunLoop ç±»åï¼
JD茅台溯源码å¯¹äº timer èè¨:
JD茅台溯源码æ¾ç¶å®æ¯è¦ä¾èµ mode çã
JD茅台溯源码CFRunLoopMode
JD茅台溯源码èä¸ä¸ª mode ä¸å对åºå¤ä¸ª items(source0ãsource1ãtimersãobservers) ï¼æ以就æå¦ä¸å ³ç³»ï¼
JD茅台溯源码æ¢ç¶æå¤ç§ mode ï¼é£ä¹é½æåªäºå¢ï¼
JD茅台溯源码æºç ä¸æå¦ä¸å®ä¹ï¼
JD茅台溯源码å®ä»¬å¯¹åº Foundation ä¸çï¼
JD茅台溯源码æ们é½æ¸ æ¥å¨é¡µé¢æ»å¨çæ¶åæä¸ä¸ª UITrackingRunLoopMode ï¼
JD茅台溯源码é¤äºä»¥ä¸ 3 ç§ mode è¿æ两个ç§æ mode ï¼
JD茅台溯源码å½ RunLoop è¿è¡å¨ Mode1 ä¸æ¶ï¼æ¯æ æ³æ¥åå¤ç Mode2 æ Mode3 ä¸ç SourceãTimerãObserver äºä»¶çã
JD茅台溯源码以 timer 为ä¾ï¼å° timer å å ¥å° runloop ä¸ï¼
JD茅台溯源码åºå±è°ç¨äº CFRunLoopAddTimer ï¼
JD茅台溯源码æ ¹æ®è¦å å ¥ç mode åºåæ¯ common mode åé common mode å° timer å å ¥ mode ä¸ãè¿ä¸ªæ¶ååªæ¯å° timer å å ¥äº mode ä¸ï¼è¦æ§è¡è¯å®è¦è°ç¨ CFRunLoopRun ï¼æç»è¦è°ç¨ CFRunLoopRunSpecific ã
JD茅台溯源码å¨ __CFRunLoopRun ä¸è°ç¨äº __CFRunLoopDoTimers ï¼
JD茅台溯源码æ¾å° mode ä¸çææ timer ç¶åè°ç¨ __CFRunLoopDoTimer ã
JD茅台溯源码CFRunLoopAddTimer -> CFRunLoopRunSpecific -> __CFRunLoopRun -> __CFRunLoopDoTimers -> __CFRunLoopDoTimer -> __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ ã
JD茅台溯源码ä¸ timer ç¸å source ä¼è°ç¨ CFRunLoopAddSource ï¼
JD茅台溯源码CFRunLoopAddSource -> CFRunLoopRunSpecific -> __CFRunLoopRun -> __CFRunLoopDoSources0/__CFRunLoopDoSources1 -> __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ /__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__
JD茅台溯源码åç observer ä¼è°ç¨ CFRunLoopAddObserver ã
JD茅台溯源码JD茅台溯源码