美文网首页iOS 多线程
runloop的5个结构体指针 CFRunLoopRef。。

runloop的5个结构体指针 CFRunLoopRef。。

作者: SmallTwo | 来源:发表于2016-08-04 17:25 被阅读166次
    typedef struct __CFRunLoop * CFRunLoopRef;
    

    CFRunLoopRef 是指向结构体 struct __CFRunLoop的指针类型

    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;
    };
    
    
    typedef struct __CFRunLoopSource * CFRunLoopSourceRef;
    

    CFRunLoopSourceRef是指向结构体struct __CFRunLoopSource的指针类型。

    struct __CFRunLoopSource {
        CFRuntimeBase _base;
        uint32_t _bits;
        pthread_mutex_t _lock;
        CFIndex _order;         /* immutable */
        CFMutableBagRef _runLoops;
        union {
        CFRunLoopSourceContext version0;    /* immutable, except invalidation */
            CFRunLoopSourceContext1 version1;   /* immutable, except invalidation */
        } _context;
    };
    
    
    typedef struct __CFRunLoopObserver * CFRunLoopObserverRef;
    

    CFRunLoopObserverRef是指向结构体 struct __CFRunLoopObserver的指针类型。

    struct __CFRunLoopObserver {
        CFRuntimeBase _base;
        pthread_mutex_t _lock;
        CFRunLoopRef _runLoop;
        CFIndex _rlCount;
        CFOptionFlags _activities;      /* immutable */
        CFIndex _order;         /* immutable */
        CFRunLoopObserverCallBack _callout; /* immutable */
        CFRunLoopObserverContext _context;  /* immutable, except invalidation */
    };
    
    
    typedef struct CF_BRIDGED_MUTABLE_TYPE(NSTimer) __CFRunLoopTimer * CFRunLoopTimerRef;
    

    CFRunLoopTimerRef是指向结构体 struct CF_BRIDGED_MUTABLE_TYPE(NSTimer)的指针类型。

    struct __CFRunLoopTimer {
        CFRuntimeBase _base;
        uint16_t _bits;
        pthread_mutex_t _lock;
        CFRunLoopRef _runLoop;
        CFMutableSetRef _rlModes;
        CFAbsoluteTime _nextFireDate;
        CFTimeInterval _interval;       /* immutable */
        CFTimeInterval _tolerance;          /* mutable */
        uint64_t _fireTSR;          /* TSR units */
        CFIndex _order;         /* immutable */
        CFRunLoopTimerCallBack _callout;    /* immutable */
        CFRunLoopTimerContext _context; /* immutable, except invalidation */
    };
    
    

    另外runloop.c中还有另外一个结构体指针。

    typedef struct __CFRunLoopMode *CFRunLoopModeRef;
    

    CFRunLoopModeRef是指向结构体struct __CFRunLoopMode的指针类型

    struct __CFRunLoopMode {
        CFRuntimeBase _base;
        pthread_mutex_t _lock;  /* must have the run loop locked before locking this */
        CFStringRef _name;
        Boolean _stopped;
        char _padding[3];
        CFMutableSetRef _sources0;
        CFMutableSetRef _sources1;
        CFMutableArrayRef _observers;
        CFMutableArrayRef _timers;
        CFMutableDictionaryRef _portToV1SourceMap;
        __CFPortSet _portSet;
        CFIndex _observerMask;
    #if USE_DISPATCH_SOURCE_FOR_TIMERS
        dispatch_source_t _timerSource;
        dispatch_queue_t _queue;
        Boolean _timerFired; // set to true by the source when a timer has fired
        Boolean _dispatchTimerArmed;
    #endif
    #if USE_MK_TIMER_TOO
        mach_port_t _timerPort;
        Boolean _mkTimerArmed;
    #endif
    #if DEPLOYMENT_TARGET_WINDOWS
        DWORD _msgQMask;
        void (*_msgPump)(void);
    #endif
        uint64_t _timerSoftDeadline; /* TSR */
        uint64_t _timerHardDeadline; /* TSR */
    };
    
    

    相关文章

      网友评论

      • SmallTwo:oc对象和c结构体指针转换
      • LoveY34:你好!我想问一下typedef struct CF_BRIDGED_MUTABLE_TYPE(NSTimer) __CFRunLoopTimer * CFRunLoopTimerRef;中CF_BRIDGED_MUTABLE_TYPE(NSTimer) 和__CFRunLoopTimer又是什么关系啊?
        SmallTwo:@LoveY34 嗯
        LoveY34:@SmallTwo 你的意思是CF_BRIDGED_MUTABLE_TYPE(NSTimer) 和__CFRunLoopTimer是等价的吗?
        SmallTwo:@LoveY34 oc和c不同框架对象转换

      本文标题:runloop的5个结构体指针 CFRunLoopRef。。

      本文链接:https://www.haomeiwen.com/subject/fkacsttx.html