iOS 开发每天分享优质文章将来跳槽用

OC底层知识(十) : RunLoop

2018-10-22  本文已影响30人  IIronMan
一、Runloop的简单介绍

Runloop 是在程序运行过程中循环做一些事情。比如应用在:定时器(NSTimer)、PerformSelector;GCD Async Main Queue;事件响应、手势识别、界面刷新、网络请求、AutoreleasePool

二、RunLoop对象的获取
三、RunLoop相关的类

Core Foundation中关于RunLoop的5个类
CFRunLoopRef
CFRunLoopModeRef
CFRunLoopSourceRef
CFRunLoopTimerRef
CFRunLoopObserverRef

struct __CFRunLoop {
    CFRuntimeBase _base;
    pthread_mutex_t _lock;                 /* locked for accessing mode list */
    __CFPort _wakeUpPort;                  // used for CFRunLoopWakeUp 
    Boolean _unused;
    volatile _per_run_data *_perRunData;   // reset for runs of the run loop
    pthread_t _pthread;
    uint32_t _winthread;
    CFMutableSetRef _commonModes;
    CFMutableSetRef _commonModeItems;
    CFRunLoopModeRef _currentMode;
    CFMutableSetRef _modes;
    struct _block_item *_blocks_head;
    struct _block_item *_blocks_tail;
    CFAbsoluteTime _runTime;
    CFAbsoluteTime _sleepTime;
    CFTypeRef _counterpart;
};
RunLoop的运行逻辑
四、RunLoop在实际开中的应用 下面练习的demo
五、RunLoop的几个面试题
上一篇 下一篇

猜你喜欢

热点阅读